--------------------------------------------------------------------------* * String array create/destroy/copy/extend * *--------------------------------------------------------------------------*/ ! * \brief sarrayCreate() * * \param[in] n size of string ptr array to be alloc'd; * use 0 for default * \return sarray, or NULL on error */
| 160 | * \return sarray, or NULL on error |
| 161 | */ |
| 162 | SARRAY * |
| 163 | sarrayCreate(l_int32 n) |
| 164 | { |
| 165 | SARRAY *sa; |
| 166 | |
| 167 | PROCNAME("sarrayCreate"); |
| 168 | |
| 169 | if (n <= 0) |
| 170 | n = INITIAL_PTR_ARRAYSIZE; |
| 171 | |
| 172 | sa = (SARRAY *)LEPT_CALLOC(1, sizeof(SARRAY)); |
| 173 | if ((sa->array = (char **)LEPT_CALLOC(n, sizeof(char *))) == NULL) { |
| 174 | sarrayDestroy(&sa); |
| 175 | return (SARRAY *)ERROR_PTR("ptr array not made", procName, NULL); |
| 176 | } |
| 177 | |
| 178 | sa->nalloc = n; |
| 179 | sa->n = 0; |
| 180 | sa->refcount = 1; |
| 181 | return sa; |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /*! |
no test coverage detected