MCPcopy Create free account
hub / github.com/RsyncProject/rsync / flist_expand

Function flist_expand

flist.c:302–333  ·  view source on GitHub ↗

Make sure flist can hold at least flist->used + extra entries. */

Source from the content-addressed store, hash-verified

300
301/* Make sure flist can hold at least flist->used + extra entries. */
302static void flist_expand(struct file_list *flist, int extra)
303{
304 struct file_struct **new_ptr;
305
306 if (flist->used + extra <= flist->malloced)
307 return;
308
309 if (flist->malloced < FLIST_START)
310 flist->malloced = FLIST_START;
311 else if (flist->malloced >= FLIST_LINEAR)
312 flist->malloced += FLIST_LINEAR;
313 else if (flist->malloced < FLIST_START_LARGE/16)
314 flist->malloced *= 4;
315 else
316 flist->malloced *= 2;
317
318 /* In case count jumped or we are starting the list
319 * with a known size just set it. */
320 if (flist->malloced < flist->used + extra)
321 flist->malloced = flist->used + extra;
322
323 new_ptr = realloc_array(flist->files, struct file_struct *, flist->malloced);
324
325 if (DEBUG_GTE(FLIST, 1) && flist->files) {
326 rprintf(FCLIENT, "[%s] expand file_list pointer array to %s bytes, did%s move\n",
327 who_am_i(),
328 big_num(sizeof flist->files[0] * flist->malloced),
329 (new_ptr == flist->files) ? " not" : "");
330 }
331
332 flist->files = new_ptr;
333}
334
335static void flist_done_allocating(struct file_list *flist)
336{

Callers 4

send_file_nameFunction · 0.85
add_dirs_to_treeFunction · 0.85
send_file_listFunction · 0.85
recv_file_listFunction · 0.85

Calls 3

big_numFunction · 0.85
rprintfFunction · 0.70
who_am_iFunction · 0.70

Tested by

no test coverage detected