248 curpos.ptr += processed; |
249 curpos.ptr += processed; |
249 curpos.length -= processed; |
250 curpos.length -= processed; |
250 |
251 |
251 /* allocate memory for the next string */ |
252 /* allocate memory for the next string */ |
252 j++; |
253 j++; |
253 sstr_t* reallocated = (sstr_t*) |
254 if (j > arrlen) { |
254 alrealloc(allocator, result, j*sizeof(sstr_t)); |
255 arrlen *= 2; |
255 if (reallocated) { |
256 sstr_t* reallocated = (sstr_t*) alrealloc( |
256 result = reallocated; |
257 allocator, result, arrlen*sizeof(sstr_t)); |
257 } else { |
258 if (reallocated) { |
258 for (ssize_t i = 0 ; i < j-1 ; i++) { |
259 result = reallocated; |
259 alfree(allocator, result[i].ptr); |
260 } else { |
|
261 for (ssize_t i = 0 ; i < j-1 ; i++) { |
|
262 alfree(allocator, result[i].ptr); |
|
263 } |
|
264 alfree(allocator, result); |
|
265 *n = -2; |
|
266 return NULL; |
260 } |
267 } |
261 alfree(allocator, result); |
|
262 *n = -2; |
|
263 return NULL; |
|
264 } |
268 } |
265 } else { |
269 } else { |
266 /* nmax reached, copy the _full_ remaining string */ |
270 /* nmax reached, copy the _full_ remaining string */ |
267 result[j-1] = sstrdup_a(allocator, curpos); |
271 result[j-1] = sstrdup_a(allocator, curpos); |
268 break; |
272 break; |