! * \brief boxaAddBox() * * \param[in] boxa * \param[in] box to be added * \param[in] copyflag L_INSERT, L_COPY, L_CLONE * \return 0 if OK, 1 on error */
| 613 | * \return 0 if OK, 1 on error |
| 614 | */ |
| 615 | l_int32 |
| 616 | boxaAddBox(BOXA *boxa, |
| 617 | BOX *box, |
| 618 | l_int32 copyflag) |
| 619 | { |
| 620 | l_int32 n; |
| 621 | BOX *boxc; |
| 622 | |
| 623 | PROCNAME("boxaAddBox"); |
| 624 | |
| 625 | if (!boxa) |
| 626 | return ERROR_INT("boxa not defined", procName, 1); |
| 627 | if (!box) |
| 628 | return ERROR_INT("box not defined", procName, 1); |
| 629 | |
| 630 | if (copyflag == L_INSERT) |
| 631 | boxc = box; |
| 632 | else if (copyflag == L_COPY) |
| 633 | boxc = boxCopy(box); |
| 634 | else if (copyflag == L_CLONE) |
| 635 | boxc = boxClone(box); |
| 636 | else |
| 637 | return ERROR_INT("invalid copyflag", procName, 1); |
| 638 | if (!boxc) |
| 639 | return ERROR_INT("boxc not made", procName, 1); |
| 640 | |
| 641 | n = boxaGetCount(boxa); |
| 642 | if (n >= boxa->nalloc) |
| 643 | boxaExtendArray(boxa); |
| 644 | boxa->box[n] = boxc; |
| 645 | boxa->n++; |
| 646 | |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | |
| 651 | /*! |
no test coverage detected