! * \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
| 118 | * </pre> |
| 119 | */ |
| 120 | void |
| 121 | lstackDestroy(L_STACK **plstack, |
| 122 | l_int32 freeflag) |
| 123 | { |
| 124 | void *item; |
| 125 | L_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 |
no test coverage detected