163 i += d.length; |
163 i += d.length; |
164 } |
164 } |
165 } |
165 } |
166 if ((*n) == nmax) break; |
166 if ((*n) == nmax) break; |
167 } |
167 } |
168 result = (sstr_t*) allocator->malloc(sizeof(sstr_t) * (*n)); |
168 result = (sstr_t*) allocator->malloc(allocator->pool, sizeof(sstr_t)*(*n)); |
169 |
169 |
170 if (result) { |
170 if (result) { |
171 char *pptr = sv.ptr; |
171 char *pptr = sv.ptr; |
172 for (size_t i = 0 ; i < *n ; i++) { |
172 for (size_t i = 0 ; i < *n ; i++) { |
173 size_t l = strlen(pptr); |
173 size_t l = strlen(pptr); |
174 char* ptr = (char*) allocator->malloc(l + 1); |
174 char* ptr = (char*) allocator->malloc(allocator->pool, l + 1); |
175 memcpy(ptr, pptr, l); |
175 memcpy(ptr, pptr, l); |
176 ptr[l] = 0; |
176 ptr[l] = 0; |
177 |
177 |
178 result[i] = sstrn(ptr, l); |
178 result[i] = sstrn(ptr, l); |
179 pptr += l + d.length; |
179 pptr += l + d.length; |