! * \brief sarrayDestroy() * * \param[in,out] psa to be nulled * \return void * * * Notes: * (1) Decrements the ref count and, if 0, destroys the sarray. * (2) Always nulls the input ptr. * */
| 352 | * </pre> |
| 353 | */ |
| 354 | void |
| 355 | sarrayDestroy(SARRAY **psa) |
| 356 | { |
| 357 | l_int32 i; |
| 358 | SARRAY *sa; |
| 359 | |
| 360 | PROCNAME("sarrayDestroy"); |
| 361 | |
| 362 | if (psa == NULL) { |
| 363 | L_WARNING("ptr address is NULL!\n", procName); |
| 364 | return; |
| 365 | } |
| 366 | if ((sa = *psa) == NULL) |
| 367 | return; |
| 368 | |
| 369 | sarrayChangeRefcount(sa, -1); |
| 370 | if (sarrayGetRefcount(sa) <= 0) { |
| 371 | if (sa->array) { |
| 372 | for (i = 0; i < sa->n; i++) { |
| 373 | if (sa->array[i]) |
| 374 | LEPT_FREE(sa->array[i]); |
| 375 | } |
| 376 | LEPT_FREE(sa->array); |
| 377 | } |
| 378 | LEPT_FREE(sa); |
| 379 | } |
| 380 | |
| 381 | *psa = NULL; |
| 382 | return; |
| 383 | } |
| 384 | |
| 385 | |
| 386 | /*! |
no test coverage detected