! * \brief lqueueDestroy() * * \param[in,out] plq 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 * cause a
| 128 | * </pre> |
| 129 | */ |
| 130 | void |
| 131 | lqueueDestroy(L_QUEUE **plq, |
| 132 | l_int32 freeflag) |
| 133 | { |
| 134 | void *item; |
| 135 | L_QUEUE *lq; |
| 136 | |
| 137 | PROCNAME("lqueueDestroy"); |
| 138 | |
| 139 | if (plq == NULL) { |
| 140 | L_WARNING("ptr address is NULL\n", procName); |
| 141 | return; |
| 142 | } |
| 143 | if ((lq = *plq) == NULL) |
| 144 | return; |
| 145 | |
| 146 | if (freeflag) { |
| 147 | while(lq->nelem > 0) { |
| 148 | item = lqueueRemove(lq); |
| 149 | LEPT_FREE(item); |
| 150 | } |
| 151 | } else if (lq->nelem > 0) { |
| 152 | L_WARNING("memory leak of %d items in lqueue!\n", procName, lq->nelem); |
| 153 | } |
| 154 | |
| 155 | if (lq->array) |
| 156 | LEPT_FREE(lq->array); |
| 157 | if (lq->stack) |
| 158 | lstackDestroy(&lq->stack, freeflag); |
| 159 | LEPT_FREE(lq); |
| 160 | *plq = NULL; |
| 161 | |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | /*--------------------------------------------------------------------------* |
no test coverage detected