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

Function boxaInsertBox

deps/leptonica/src/boxbasic.c:980–1007  ·  view source on GitHub ↗

! * \brief boxaInsertBox() * * \param[in] boxa * \param[in] index location in boxa to insert new value * \param[in] box new box to be inserted * \return 0 if OK, 1 on error * * * Notes: * (1) This shifts box[i] --> box[i + 1] for all i >= index, * and then inserts box as box[index]. * (2) To insert at the beginning of the array, set index = 0. *

Source from the content-addressed store, hash-verified

978 * </pre>
979 */
980l_int32
981boxaInsertBox(BOXA *boxa,
982 l_int32 index,
983 BOX *box)
984{
985l_int32 i, n;
986BOX **array;
987
988 PROCNAME("boxaInsertBox");
989
990 if (!boxa)
991 return ERROR_INT("boxa not defined", procName, 1);
992 n = boxaGetCount(boxa);
993 if (index < 0 || index > n)
994 return ERROR_INT("index not in {0...n}", procName, 1);
995 if (!box)
996 return ERROR_INT("box not defined", procName, 1);
997
998 if (n >= boxa->nalloc)
999 boxaExtendArray(boxa);
1000 array = boxa->box;
1001 boxa->n++;
1002 for (i = n; i > index; i--)
1003 array[i] = array[i - 1];
1004 array[index] = box;
1005
1006 return 0;
1007}
1008
1009
1010/*!

Callers 1

pixaInsertPixFunction · 0.85

Calls 2

boxaGetCountFunction · 0.85
boxaExtendArrayFunction · 0.85

Tested by

no test coverage detected