Merge branch 'ab/free-and-null'
A common pattern to free a piece of memory and assign NULL to the pointer that used to point at it has been replaced with a new FREE_AND_NULL() macro. * ab/free-and-null: *.[ch] refactoring: make use of the FREE_AND_NULL() macro coccinelle: make use of the "expression" FREE_AND_NULL() rule coccinelle: add a rule to make "expression" code use FREE_AND_NULL() coccinelle: make use of the "type" FREE_AND_NULL() rule coccinelle: add a rule to make "type" code use FREE_AND_NULL() git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL
This commit is contained in:
@ -265,8 +265,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
|
||||
* make sure no cached delta data remains from a
|
||||
* previous attempt before a pack split occurred.
|
||||
*/
|
||||
free(entry->delta_data);
|
||||
entry->delta_data = NULL;
|
||||
FREE_AND_NULL(entry->delta_data);
|
||||
entry->z_delta_size = 0;
|
||||
} else if (entry->delta_data) {
|
||||
size = entry->delta_size;
|
||||
@ -1376,12 +1375,10 @@ static void cleanup_preferred_base(void)
|
||||
if (!pbase_tree_cache[i])
|
||||
continue;
|
||||
free(pbase_tree_cache[i]->tree_data);
|
||||
free(pbase_tree_cache[i]);
|
||||
pbase_tree_cache[i] = NULL;
|
||||
FREE_AND_NULL(pbase_tree_cache[i]);
|
||||
}
|
||||
|
||||
free(done_pbase_paths);
|
||||
done_pbase_paths = NULL;
|
||||
FREE_AND_NULL(done_pbase_paths);
|
||||
done_pbase_paths_num = done_pbase_paths_alloc = 0;
|
||||
}
|
||||
|
||||
@ -1971,8 +1968,7 @@ static unsigned long free_unpacked(struct unpacked *n)
|
||||
n->index = NULL;
|
||||
if (n->data) {
|
||||
freed_mem += n->entry->size;
|
||||
free(n->data);
|
||||
n->data = NULL;
|
||||
FREE_AND_NULL(n->data);
|
||||
}
|
||||
n->entry = NULL;
|
||||
n->depth = 0;
|
||||
|
Reference in New Issue
Block a user