/*! * ptraExtendArray() * * Input: ptra * Return: 0 if OK, 1 on error */ static l_int32 ptraExtendArray(L_PTRA *pa) { PROCNAME("ptraExtendArray"); if (!pa) return ERROR_INT("pa not defined", procName, 1); if ((pa->array = (void **) reallocNew((void **) &pa->array, sizeof(void *) * pa->nalloc, 2 * sizeof(void *) * pa->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); pa->nalloc *= 2; return 0; }
/*! * sarrayExtendArray() * * Input: sarray * Return: 0 if OK, 1 on error */ l_int32 sarrayExtendArray(SARRAY *sa) { PROCNAME("sarrayExtendArray"); if (!sa) return ERROR_INT("sa not defined", procName, 1); if ((sa->array = (char **)reallocNew((void **)&sa->array, sizeof(char *) * sa->nalloc, 2 * sizeof(char *) * sa->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); sa->nalloc *= 2; return 0; }
/*! * lstackExtendArray() * * Input: lstack * Return: 0 if OK; 1 on error */ static l_int32 lstackExtendArray(L_STACK *lstack) { PROCNAME("lstackExtendArray"); if (!lstack) return ERROR_INT("lstack not defined", procName, 1); if ((lstack->array = (void **)reallocNew((void **)&lstack->array, sizeof(void *) * lstack->nalloc, 2 * sizeof(void *) * lstack->nalloc)) == NULL) return ERROR_INT("new lstack array not defined", procName, 1); lstack->nalloc = 2 * lstack->nalloc; return 0; }
/*! * numaaExtendArray() * * Input: naa * Return: 0 if OK, 1 on error */ l_int32 numaaExtendArray(NUMAA *naa) { PROCNAME("numaaExtendArray"); if (!naa) return ERROR_INT("naa not defined", procName, 1); if ((naa->numa = (NUMA **)reallocNew((void **)&naa->numa, sizeof(NUMA *) * naa->nalloc, 2 * sizeof(NUMA *) * naa->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); naa->nalloc *= 2; return 0; }
/*! * lqueueExtendArray() * * Input: lqueue * Return: 0 if OK, 1 on error */ l_int32 lqueueExtendArray(L_QUEUE *lq) { PROCNAME("lqueueExtendArray"); if (!lq) return ERROR_INT("lq not defined", procName, 1); if ((lq->array = (void **)reallocNew((void **)&lq->array, sizeof(void *) * lq->nalloc, 2 * sizeof(void *) * lq->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); lq->nalloc = 2 * lq->nalloc; return 0; }
/*! * l_dnaExtendArray() * * Input: da * Return: 0 if OK, 1 on error */ static l_int32 l_dnaExtendArray(L_DNA *da) { PROCNAME("l_dnaExtendArray"); if (!da) return ERROR_INT("da not defined", procName, 1); if ((da->array = (l_float64 *)reallocNew((void **)&da->array, sizeof(l_float64) * da->nalloc, 2 * sizeof(l_float64) * da->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); da->nalloc *= 2; return 0; }
/*! * lheapExtendArray() * * Input: lheap * Return: 0 if OK, 1 on error */ static l_int32 lheapExtendArray(L_HEAP *lh) { PROCNAME("lheapExtendArray"); if (!lh) return ERROR_INT("lh not defined", procName, 1); if ((lh->array = (void **)reallocNew((void **)&lh->array, sizeof(void *) * lh->nalloc, 2 * sizeof(void *) * lh->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); lh->nalloc = 2 * lh->nalloc; return 0; }
/*! * recogaExtendArray() * * Input: recoga * Return: 0 if OK, 1 on error */ static l_int32 recogaExtendArray(L_RECOGA *recoga) { PROCNAME("recogaExtendArray"); if (!recoga) return ERROR_INT("recogaa not defined", procName, 1); if ((recoga->recog = (L_RECOG **)reallocNew((void **)&recoga->recog, sizeof(L_RECOG *) * recoga->nalloc, 2 * sizeof(L_RECOG *) * recoga->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); recoga->nalloc *= 2; return 0; }
/*! * pixaaExtendArray() * * Input: pixaa * Return: 0 if OK; 1 on error */ l_int32 pixaaExtendArray(PIXAA *pixaa) { PROCNAME("pixaaExtendArray"); if (!pixaa) return ERROR_INT("pixaa not defined", procName, 1); if ((pixaa->pixa = (PIXA **)reallocNew((void **)&pixaa->pixa, sizeof(PIXA *) * pixaa->nalloc, 2 * sizeof(PIXA *) * pixaa->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); pixaa->nalloc = 2 * pixaa->nalloc; return 0; }
/*! * numaExtendArray() * * Input: na * Return: 0 if OK, 1 on error */ static l_int32 numaExtendArray(NUMA *na) { PROCNAME("numaExtendArray"); if (!na) return ERROR_INT("na not defined", procName, 1); if ((na->array = (l_float32 *)reallocNew((void **)&na->array, sizeof(l_float32) * na->nalloc, 2 * sizeof(l_float32) * na->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); na->nalloc *= 2; return 0; }
/*! * boxaaExtendArray() * * Input: boxaa * Return: 0 if OK, 1 on error */ l_int32 boxaaExtendArray(BOXAA *baa) { PROCNAME("boxaaExtendArray"); if (!baa) return ERROR_INT("baa not defined", procName, 1); if ((baa->boxa = (BOXA **)reallocNew((void **)&baa->boxa, sizeof(BOXA *) * baa->nalloc, 2 * sizeof(BOXA *) * baa->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); baa->nalloc *= 2; return 0; }
/*! * bbufferExtendArray() * * Input: bbuffer * nbytes (number of bytes to extend array size) * Return: 0 if OK, 1 on error * * Notes: * (1) reallocNew() copies all bb->nalloc bytes, even though * only bb->n are data. */ static l_int32 bbufferExtendArray(BBUFFER *bb, l_int32 nbytes) { PROCNAME("bbufferExtendArray"); if (!bb) return ERROR_INT("bb not defined", procName, 1); if ((bb->array = (l_uint8 *)reallocNew((void **)&bb->array, bb->nalloc, bb->nalloc + nbytes)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); bb->nalloc += nbytes; return 0; }
/*! * boxaExtendArray() * * Input: boxa * Return: 0 if OK; 1 on error */ l_int32 boxaExtendArray(BOXA *boxa) { PROCNAME("boxaExtendArray"); if (!boxa) return ERROR_INT("boxa not defined", procName, 1); if ((boxa->box = (BOX **)reallocNew((void **)&boxa->box, sizeof(BOX *) * boxa->nalloc, 2 * sizeof(BOX *) * boxa->nalloc)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); boxa->nalloc = 2 * boxa->nalloc; return 0; }
/*! * l_dnaSetCount() * * Input: da * newcount * Return: 0 if OK, 1 on error * * Notes: * (1) If newcount <= da->nalloc, this resets da->n. * Using newcount = 0 is equivalent to l_dnaEmpty(). * (2) If newcount > da->nalloc, this causes a realloc * to a size da->nalloc = newcount. * (3) All the previously unused values in da are set to 0.0. */ l_int32 l_dnaSetCount(L_DNA *da, l_int32 newcount) { PROCNAME("l_dnaSetCount"); if (!da) return ERROR_INT("da not defined", procName, 1); if (newcount > da->nalloc) { if ((da->array = (l_float64 *)reallocNew((void **)&da->array, sizeof(l_float64) * da->nalloc, sizeof(l_float64) * newcount)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); da->nalloc = newcount; } da->n = newcount; return 0; }
/*! * pixaExtendArrayToSize() * * Input: pixa * Return: 0 if OK; 1 on error * * Notes: * (1) If necessary, reallocs new pixa and boxa ptrs arrays to @size. * The pixa and boxa ptr arrays must always be equal in size. */ l_int32 pixaExtendArrayToSize(PIXA *pixa, l_int32 size) { PROCNAME("pixaExtendArrayToSize"); if (!pixa) return ERROR_INT("pixa not defined", procName, 1); if (size > pixa->nalloc) { if ((pixa->pix = (PIX **)reallocNew((void **)&pixa->pix, sizeof(PIX *) * pixa->nalloc, size * sizeof(PIX *))) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); pixa->nalloc = size; } return boxaExtendArrayToSize(pixa->boxa, size); }
/*! * boxaExtendArrayToSize() * * Input: boxa * size (new size of boxa array) * Return: 0 if OK; 1 on error * * Notes: * (1) If necessary, reallocs new boxa ptr array to @size. */ l_int32 boxaExtendArrayToSize(BOXA *boxa, l_int32 size) { PROCNAME("boxaExtendArrayToSize"); if (!boxa) return ERROR_INT("boxa not defined", procName, 1); if (size > boxa->nalloc) { if ((boxa->box = (BOX **)reallocNew((void **)&boxa->box, sizeof(BOX *) * boxa->nalloc, size * sizeof(BOX *))) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); boxa->nalloc = size; } return 0; }
/*! * numaSetCount() * * Input: na * newcount * Return: 0 if OK, 1 on error * * Notes: * (1) If newcount <= na->nalloc, this resets na->n. * Using newcount = 0 is equivalent to numaEmpty(). * (2) If newcount > na->nalloc, this causes a realloc * to a size na->nalloc = newcount. * (3) All the previously unused values in na are set to 0.0. */ l_int32 numaSetCount(NUMA *na, l_int32 newcount) { PROCNAME("numaSetCount"); if (!na) return ERROR_INT("na not defined", procName, 1); if (newcount > na->nalloc) { if ((na->array = (l_float32 *)reallocNew((void **)&na->array, sizeof(l_float32) * na->nalloc, sizeof(l_float32) * newcount)) == NULL) return ERROR_INT("new ptr array not returned", procName, 1); na->nalloc = newcount; } na->n = newcount; return 0; }
/*! * l_byteaExtendArrayToSize() * * Input: ba * size (new size of lba data array) * Return: 0 if OK; 1 on error */ l_int32 l_byteaExtendArrayToSize(L_BYTEA *ba, size_t size) { PROCNAME("l_byteaExtendArrayToSize"); if (!ba) return ERROR_INT("ba not defined", procName, 1); if (size > ba->nalloc) { if ((ba->data = (l_uint8 *)reallocNew((void **)&ba->data, ba->nalloc, size)) == NULL) return ERROR_INT("new array not returned", procName, 1); ba->nalloc = size; } return 0; }