MCPcopy Create free account
hub / github.com/creatale/node-dv / bpmnode_create

Function bpmnode_create

deps/lodepng/lodepng.cpp:706–736  ·  view source on GitHub ↗

creates a new chain node with the given parameters, from the memory in the lists */

Source from the content-addressed store, hash-verified

704
705/*creates a new chain node with the given parameters, from the memory in the lists */
706static BPMNode* bpmnode_create(BPMLists* lists, int weight, unsigned index, BPMNode* tail)
707{
708 unsigned i;
709 BPMNode* result;
710
711 /*memory full, so garbage collect*/
712 if(lists->nextfree >= lists->numfree)
713 {
714 /*mark only those that are in use*/
715 for(i = 0; i != lists->memsize; ++i) lists->memory[i].in_use = 0;
716 for(i = 0; i != lists->listsize; ++i)
717 {
718 BPMNode* node;
719 for(node = lists->chains0[i]; node != 0; node = node->tail) node->in_use = 1;
720 for(node = lists->chains1[i]; node != 0; node = node->tail) node->in_use = 1;
721 }
722 /*collect those that are free*/
723 lists->numfree = 0;
724 for(i = 0; i != lists->memsize; ++i)
725 {
726 if(!lists->memory[i].in_use) lists->freelist[lists->numfree++] = &lists->memory[i];
727 }
728 lists->nextfree = 0;
729 }
730
731 result = lists->freelist[lists->nextfree++];
732 result->weight = weight;
733 result->index = index;
734 result->tail = tail;
735 return result;
736}
737
738/*sort the leaves with stable mergesort*/
739static void bpmnode_sort(BPMNode* leaves, size_t num)

Callers 2

boundaryPMFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected