diff options
author | Wayne Davison <wayne@opencoder.net> | 2020-06-25 19:59:19 -0700 |
---|---|---|
committer | Wayne Davison <wayne@opencoder.net> | 2020-06-25 20:54:21 -0700 |
commit | 11eb67eec9b4d990ae4df680cf7db77dad1b8630 (patch) | |
tree | 977f60274b7784ad12854bbe575503bae46c3e6c /hlink.c | |
parent | 39a083b16b6d229f32078569ea8bd2c4bb29a44b (diff) | |
download | rsync-11eb67eec9b4d990ae4df680cf7db77dad1b8630.tar.gz |
Some memory allocation improvements
- All the memory-allocation macros now auto-check for failure and exit
with a failure message that incudes the caller's file and lineno
info. This includes strdup().
- Added the `--max-alloc=SIZE` option to be able to override the memory
allocator's sanity-check limit. It defaults to 1G (as before).
Fixes bugzilla bug 12769.
Diffstat (limited to 'hlink.c')
-rw-r--r-- | hlink.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -125,8 +125,7 @@ static void match_gnums(int32 *ndx_list, int ndx_count) if (inc_recurse) { node = hashtable_find(prior_hlinks, gnum, data_when_new); if (node->data == data_when_new) { - if (!(node->data = new_array0(char, 5))) - out_of_memory("match_gnums"); + node->data = new_array0(char, 5); assert(gnum >= hlink_flist->ndx_start); file->flags |= FLAG_HLINK_FIRST; prev = -1; @@ -190,8 +189,7 @@ void match_hard_links(struct file_list *flist) int i, ndx_count = 0; int32 *ndx_list; - if (!(ndx_list = new_array(int32, flist->used))) - out_of_memory("match_hard_links"); + ndx_list = new_array(int32, flist->used); for (i = 0; i < flist->used; i++) { if (F_IS_HLINKED(flist->sorted[i])) @@ -541,8 +539,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx, exit_cleanup(RERR_MESSAGEIO); } free(node->data); - if (!(node->data = strdup(our_name))) - out_of_memory("finish_hard_link"); + node->data = strdup(our_name); } } |