! * \brief boxaSaveValid() * * \param[in] boxas * \param[in] copyflag L_COPY or L_CLONE * \return boxad if OK, NULL on error * * * Notes: * (1) This makes a copy/clone of each valid box. * */
| 1107 | * </pre> |
| 1108 | */ |
| 1109 | BOXA * |
| 1110 | boxaSaveValid(BOXA *boxas, |
| 1111 | l_int32 copyflag) |
| 1112 | { |
| 1113 | l_int32 i, n; |
| 1114 | BOX *box; |
| 1115 | BOXA *boxad; |
| 1116 | |
| 1117 | PROCNAME("boxaSaveValid"); |
| 1118 | |
| 1119 | if (!boxas) |
| 1120 | return (BOXA *)ERROR_PTR("boxas not defined", procName, NULL); |
| 1121 | if (copyflag != L_COPY && copyflag != L_CLONE) |
| 1122 | return (BOXA *)ERROR_PTR("invalid copyflag", procName, NULL); |
| 1123 | |
| 1124 | n = boxaGetCount(boxas); |
| 1125 | boxad = boxaCreate(n); |
| 1126 | for (i = 0; i < n; i++) { |
| 1127 | if ((box = boxaGetValidBox(boxas, i, copyflag)) != NULL) |
| 1128 | boxaAddBox(boxad, box, L_INSERT); |
| 1129 | } |
| 1130 | |
| 1131 | return boxad; |
| 1132 | } |
| 1133 | |
| 1134 | |
| 1135 | /*! |
no test coverage detected