MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / bpmnode_create

Function bpmnode_create

external/lodepng/lodepng.cpp:694–724  ·  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

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

Callers 2

boundaryPMFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected