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

Function lstackDestroy

deps/leptonica/src/stack.c:120–152  ·  view source on GitHub ↗

! * \brief lstackDestroy() * * \param[in,out] plstack to be nulled * \param[in] freeflag TRUE to free each remaining struct in the array * \return void * * * Notes: * (1) If freeflag is TRUE, frees each struct in the array. * (2) If freeflag is FALSE but there are elements on the array, * gives a warning and destroys the array. This will * cau

Source from the content-addressed store, hash-verified

118 * </pre>
119 */
120void
121lstackDestroy(L_STACK **plstack,
122 l_int32 freeflag)
123{
124void *item;
125L_STACK *lstack;
126
127 PROCNAME("lstackDestroy");
128
129 if (plstack == NULL) {
130 L_WARNING("ptr address is NULL\n", procName);
131 return;
132 }
133 if ((lstack = *plstack) == NULL)
134 return;
135
136 if (freeflag) {
137 while(lstack->n > 0) {
138 item = lstackRemove(lstack);
139 LEPT_FREE(item);
140 }
141 } else if (lstack->n > 0) {
142 L_WARNING("memory leak of %d items in lstack\n", procName, lstack->n);
143 }
144
145 if (lstack->auxstack)
146 lstackDestroy(&lstack->auxstack, freeflag);
147
148 if (lstack->array)
149 LEPT_FREE(lstack->array);
150 LEPT_FREE(lstack);
151 *plstack = NULL;
152}
153
154
155

Callers 6

lqueueDestroyFunction · 0.85
pixConnCompPixaFunction · 0.85
pixConnCompBBFunction · 0.85
pixCountConnCompFunction · 0.85
lstackCreateFunction · 0.85
wshedApplyFunction · 0.85

Calls 1

lstackRemoveFunction · 0.85

Tested by

no test coverage detected