#if TCHAR_IS_UTF16LE
name_utf16le_nbytes = tstrlen(name) * sizeof(utf16lechar);
name_utf16le = MALLOC(name_utf16le_nbytes + sizeof(utf16lechar));
- if (!name_utf16le)
+ if (name_utf16le == NULL)
return WIMLIB_ERR_NOMEM;
memcpy(name_utf16le, name, name_utf16le_nbytes + sizeof(utf16lechar));
ret = 0;
{
int ret;
- if (!root)
+ if (root == NULL)
return 0;
ret = (*visitor)(root, arg);
if (ret)
{
int ret;
- if (!root)
+ if (root == NULL)
return 0;
ret = for_dentry_tree_in_rbtree_depth(root->d_inode->i_children.rb_node,
visitor, arg);
if (dentry_is_root(dentry)) {
static const tchar _root_path[] = {WIM_PATH_SEPARATOR, T('\0')};
full_path = TSTRDUP(_root_path);
- if (!full_path)
+ if (full_path == NULL)
return WIMLIB_ERR_NOMEM;
full_path_nbytes = 1 * sizeof(tchar);
} else {
parent_full_path = T("");
parent_full_path_nbytes = 0;
} else {
- if (!parent->_full_path) {
+ if (parent->_full_path == NULL) {
ret = calculate_dentry_full_path(parent);
if (ret)
return ret;
full_path_nbytes = parent_full_path_nbytes + sizeof(tchar) +
filename_nbytes;
full_path = MALLOC(full_path_nbytes + sizeof(tchar));
- if (!full_path)
+ if (full_path == NULL)
return WIMLIB_ERR_NOMEM;
memcpy(full_path, parent_full_path, parent_full_path_nbytes);
full_path[parent_full_path_nbytes / sizeof(tchar)] = WIM_PATH_SEPARATOR;
const utf16lechar *p, *pp;
cur_dentry = parent_dentry = wim_root_dentry(wim);
- if (!cur_dentry) {
+ if (cur_dentry == NULL) {
errno = ENOENT;
return NULL;
}
int ret;
dentry = MALLOC(sizeof(struct wim_dentry));
- if (!dentry)
+ if (dentry == NULL)
return WIMLIB_ERR_NOMEM;
dentry_common_init(dentry);
dentry->d_inode = new_timeless_inode();
else
dentry->d_inode = new_inode();
- if (!dentry->d_inode) {
+ if (dentry->d_inode == NULL) {
free_dentry(dentry);
return WIMLIB_ERR_NOMEM;
}
if (is_utf16le) {
utf16lechar *p = MALLOC(name_nbytes + sizeof(utf16lechar));
- if (!p)
+ if (p == NULL)
return WIMLIB_ERR_NOMEM;
memcpy(p, name, name_nbytes);
p[name_nbytes / 2] = cpu_to_le16(0);
num_ads = inode->i_num_ads + 1;
ads_entries = REALLOC(inode->i_ads_entries,
num_ads * sizeof(inode->i_ads_entries[0]));
- if (!ads_entries) {
+ if (ads_entries == NULL) {
ERROR("Failed to allocate memory for new alternate data stream");
return NULL;
}
sha1_buffer(buffer, size, hash);
existing_lte = lookup_resource(lookup_table, hash);
if (existing_lte) {
- wimlib_assert(wim_resource_size(existing_lte) == size);
+ wimlib_assert(existing_lte->size == size);
lte = existing_lte;
lte->refcnt++;
} else {
void *buffer_copy;
lte = new_lookup_table_entry();
- if (!lte)
+ if (lte == NULL)
return NULL;
buffer_copy = memdup(buffer, size);
- if (!buffer_copy) {
+ if (buffer_copy == NULL) {
free_lookup_table_entry(lte);
return NULL;
}
- lte->resource_location = RESOURCE_IN_ATTACHED_BUFFER;
- lte->attached_buffer = buffer_copy;
- lte->resource_entry.original_size = size;
+ lte->resource_location = RESOURCE_IN_ATTACHED_BUFFER;
+ lte->attached_buffer = buffer_copy;
+ lte->size = size;
copy_hash(lte->hash, hash);
lookup_table_insert(lookup_table, lte);
}
wimlib_assert(inode->i_resolved);
new_ads_entry = inode_add_ads(inode, name);
- if (!new_ads_entry)
+ if (new_ads_entry == NULL)
return WIMLIB_ERR_NOMEM;
new_ads_entry->lte = add_stream_from_data_buffer(value, size,
lookup_table);
- if (!new_ads_entry->lte) {
+ if (new_ads_entry->lte == NULL) {
inode_remove_ads(inode, new_ads_entry - inode->i_ads_entries,
lookup_table);
return WIMLIB_ERR_NOMEM;
struct wim_lookup_table *lookup_table)
{
inode->i_lte = add_stream_from_data_buffer(data, len, lookup_table);
- if (!inode->i_lte)
+ if (inode->i_lte == NULL)
return WIMLIB_ERR_NOMEM;
inode->i_resolved = 1;
return 0;
ads_entry = inode_get_ads_entry((struct wim_inode*)inode,
WIMLIB_UNIX_DATA_TAG, NULL);
- if (!ads_entry)
+ if (ads_entry == NULL)
return NO_UNIX_DATA;
if (stream_idx_ret)
*stream_idx_ret = ads_entry - inode->i_ads_entries;
lte = ads_entry->lte;
- if (!lte)
+ if (lte == NULL)
return NO_UNIX_DATA;
- size = wim_resource_size(lte);
+ size = lte->size;
if (size != sizeof(struct wimlib_unix_data))
return BAD_UNIX_DATA;
- ret = read_full_resource_into_buf(lte, unix_data);
+ ret = read_full_stream_into_buf(lte, unix_data);
if (ret)
return ret;
* data stream entries. */
num_ads = inode->i_num_ads;
ads_entries = CALLOC(num_ads, sizeof(inode->i_ads_entries[0]));
- if (!ads_entries)
+ if (ads_entries == NULL)
goto out_of_memory;
/* Read the entries into our newly allocated buffer. */
goto out_invalid;
cur_entry->stream_name = MALLOC(cur_entry->stream_name_nbytes + 2);
- if (!cur_entry->stream_name)
+ if (cur_entry->stream_name == NULL)
goto out_of_memory;
memcpy(cur_entry->stream_name,
/* Allocate a `struct wim_inode' for this `struct wim_dentry'. */
inode = new_timeless_inode();
- if (!inode)
+ if (inode == NULL)
return WIMLIB_ERR_NOMEM;
/* Read more fields; some into the dentry, and some into the inode. */
* is no null terminator following it. */
if (file_name_nbytes) {
file_name = MALLOC(file_name_nbytes + 2);
- if (!file_name) {
+ if (file_name == NULL) {
ERROR("Failed to allocate %d bytes for dentry file name",
file_name_nbytes + 2);
ret = WIMLIB_ERR_NOMEM;
* filename, there is no null terminator following it. */
if (short_name_nbytes) {
short_name = MALLOC(short_name_nbytes + 2);
- if (!short_name) {
+ if (short_name == NULL) {
ERROR("Failed to allocate %d bytes for dentry short name",
short_name_nbytes + 2);
ret = WIMLIB_ERR_NOMEM;
/* Not end of directory. Allocate this child permanently and
* link it to the parent and previous child. */
child = memdup(&cur_child, sizeof(struct wim_dentry));
- if (!child) {
+ if (child == NULL) {
ERROR("Failed to allocate new dentry!");
ret = WIMLIB_ERR_NOMEM;
break;
wdentry = CALLOC(1, sizeof(struct wimlib_dir_entry) +
(1 + dentry->d_inode->i_num_ads) *
sizeof(struct wimlib_stream_entry));
- if (!wdentry)
+ if (wdentry == NULL)
goto out;
ret = init_wimlib_dentry(wdentry, dentry, wim, flags);
struct wim_dentry *dentry;
dentry = get_dentry(wim, ctx->path);
- if (!dentry)
+ if (dentry == NULL)
return WIMLIB_ERR_PATH_DOES_NOT_EXIST;
return do_iterate_dir_tree(wim, dentry, ctx->flags, ctx->cb, ctx->user_ctx);
}
/* Compare stream sizes. */
if (lte && template_lte) {
- if (wim_resource_size(lte) != wim_resource_size(template_lte))
+ if (lte->size != template_lte->size)
return false;
/* If hash happens to be available, compare with template. */
!hashes_equal(lte->hash, template_lte->hash))
return false;
- } else if (lte && wim_resource_size(lte)) {
+ } else if (lte && lte->size) {
return false;
- } else if (template_lte && wim_resource_size(template_lte)) {
+ } else if (template_lte && template_lte->size) {
return false;
}
}
/* Only take action if both entries exist, the entry for @inode
* has no checksum calculated, but the entry for @template_inode
* does. */
- if (!lte || !template_lte ||
+ if (lte == NULL || template_lte == NULL ||
!lte->unhashed || template_lte->unhashed)
continue;
return ret;
template_dentry = get_dentry(template_wim, dentry->_full_path);
- if (!template_dentry) {
+ if (template_dentry == NULL) {
DEBUG("\"%"TS"\": newly added file", dentry->_full_path);
return 0;
}