MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / pqueue_init_full

Function pqueue_init_full

libCacheSim/dataStructure/pqueue.c:52–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52pqueue_t *
53pqueue_init_full(size_t n,
54 pqueue_cmp_pri_f cmppri,
55 pqueue_get_pri_f getpri,
56 pqueue_set_pri_f setpri,
57 pqueue_get_pos_f getpos,
58 pqueue_set_pos_f setpos)
59{
60 pqueue_t *q;
61
62 if (!(q = malloc(sizeof(pqueue_t))))
63 return NULL;
64
65 /* Need to allocate n+1 elements since element 0 isn't used. */
66 if (!(q->d = malloc((n + 1) * sizeof(void *)))) {
67 free(q);
68 return NULL;
69 }
70
71 q->size = 1;
72 q->avail = q->step = (n+1); /* see comment above about n+1 */
73 q->cmppri = cmppri;
74 q->setpri = setpri;
75 q->getpri = getpri;
76 q->getpos = getpos;
77 q->setpos = setpos;
78
79 return q;
80}
81
82
83void

Callers 2

pqueue_initFunction · 0.85
pqueue_printFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected