diff options
author | Wayne Davison <wayne@opencoder.net> | 2020-07-05 17:04:37 -0700 |
---|---|---|
committer | Wayne Davison <wayne@opencoder.net> | 2020-07-05 17:25:53 -0700 |
commit | e1e4ffe057346de61972b2d995ebc9c720a7d8bd (patch) | |
tree | 6865a44a8d2caca26811fcb11b7ab23e97aedd9b /flist.c | |
parent | 1b53b2ff4be476eee15d98d48f68cb1bead0bd77 (diff) | |
download | rsync-e1e4ffe057346de61972b2d995ebc9c720a7d8bd.tar.gz |
Some C99 flexible array changes
- Use C99 flexible arrays when possible, and fall back on the existing
fname[1] kluges on older compilers.
- Avoid static initialization of a flexible array, which is not really
in the C standard.
Diffstat (limited to 'flist.c')
-rw-r--r-- | flist.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -1892,7 +1892,7 @@ static void send_implied_dirs(int f, struct file_list *flist, char *fname, memcpy(F_DIR_RELNAMES_P(lastpath_struct), &relname_list, sizeof relname_list); } rnpp = EXPAND_ITEM_LIST(relname_list, relnamecache *, 32); - *rnpp = (relnamecache*)new_array(char, sizeof (relnamecache) + len); + *rnpp = (relnamecache*)new_array(char, RELNAMECACHE_LEN + len + 1); (*rnpp)->name_type = name_type; strlcpy((*rnpp)->fname, limit+1, len + 1); @@ -2051,8 +2051,7 @@ void send_extra_file_list(int f, int at_least) if (need_unsorted_flist) { flist->sorted = new_array(struct file_struct *, flist->used); - memcpy(flist->sorted, flist->files, - flist->used * sizeof (struct file_struct*)); + memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE); } else flist->sorted = flist->files; @@ -2405,8 +2404,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) * send them together in a single file-list. */ if (need_unsorted_flist) { flist->sorted = new_array(struct file_struct *, flist->used); - memcpy(flist->sorted, flist->files, - flist->used * sizeof (struct file_struct*)); + memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE); } else flist->sorted = flist->files; flist_sort_and_clean(flist, 0); @@ -2587,8 +2585,7 @@ struct file_list *recv_file_list(int f, int dir_ndx) * list unsorted for our exchange of index numbers with the * other side (since their names may not sort the same). */ flist->sorted = new_array(struct file_struct *, flist->used); - memcpy(flist->sorted, flist->files, - flist->used * sizeof (struct file_struct*)); + memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE); if (inc_recurse && dir_flist->used > dstart) { static int dir_flist_malloced = 0; if (dir_flist_malloced < dir_flist->malloced) { @@ -2598,7 +2595,7 @@ struct file_list *recv_file_list(int f, int dir_ndx) dir_flist_malloced = dir_flist->malloced; } memcpy(dir_flist->sorted + dstart, dir_flist->files + dstart, - (dir_flist->used - dstart) * sizeof (struct file_struct*)); + (dir_flist->used - dstart) * PTR_SIZE); fsort(dir_flist->sorted + dstart, dir_flist->used - dstart); } } else { |