MCPcopy Create free account
hub / github.com/TurningWheel/Barony / list_Copy

Function list_Copy

src/list.cpp:396–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394-------------------------------------------------------------------------------*/
395
396list_t* list_Copy(list_t* destlist, list_t* srclist)
397{
398 node_t* node;
399 for ( node = srclist->first; node != NULL; node = node->next )
400 {
401 if ( node->size == 0 )
402 {
403 printlog("error: attempted copy of node with size 0! Node not copied\n");
404 continue;
405 }
406 node_t* newnode = list_AddNodeLast(destlist);
407 newnode->deconstructor = node->deconstructor;
408 newnode->element = malloc(node->size);
409 newnode->size = node->size;
410 memcpy(newnode->element, node->element, node->size);
411 }
412
413 return destlist;
414}
415
416/*-------------------------------------------------------------------------------
417

Callers 3

scoreConstructorFunction · 0.85
loadScoreFunction · 0.85
copyStatsMethod · 0.85

Calls 2

printlogFunction · 0.85
list_AddNodeLastFunction · 0.85

Tested by

no test coverage detected