199 ret.ptr = s.ptr + pos; |
199 ret.ptr = s.ptr + pos; |
200 } |
200 } |
201 return ret; |
201 return ret; |
202 } |
202 } |
203 |
203 |
204 scstr_t scstrsubs(scstr_t s, size_t start) { |
204 scstr_t scstrsubs(scstr_t string, size_t start) { |
205 return scstrsubsl (s, start, s.length-start); |
205 return scstrsubsl(string, start, string.length-start); |
206 } |
206 } |
207 |
207 |
208 scstr_t scstrsubsl(scstr_t s, size_t start, size_t length) { |
208 scstr_t scstrsubsl(scstr_t s, size_t start, size_t length) { |
209 size_t pos; |
209 size_t pos; |
210 scstr_t ret = { NULL, 0 }; |
210 scstr_t ret = { NULL, 0 }; |
213 } |
213 } |
214 return ret; |
214 return ret; |
215 } |
215 } |
216 |
216 |
217 |
217 |
218 int ucx_strchr(const char *string, size_t length, int chr, size_t *pos) { |
218 static int ucx_strchr(const char *str, size_t length, int chr, size_t *pos) { |
219 for(size_t i=0;i<length;i++) { |
219 for(size_t i=0;i<length;i++) { |
220 if(string[i] == chr) { |
220 if(str[i] == chr) { |
221 *pos = i; |
221 *pos = i; |
222 return 1; |
222 return 1; |
223 } |
223 } |
224 } |
224 } |
225 return 0; |
225 return 0; |
226 } |
226 } |
227 |
227 |
228 int ucx_strrchr(const char *string, size_t length, int chr, size_t *pos) { |
228 static int ucx_strrchr(const char *str, size_t length, int chr, size_t *pos) { |
229 if(length > 0) { |
229 if(length > 0) { |
230 for(size_t i=length ; i>0 ; i--) { |
230 for(size_t i=length ; i>0 ; i--) { |
231 if(string[i-1] == chr) { |
231 if(str[i-1] == chr) { |
232 *pos = i-1; |
232 *pos = i-1; |
233 return 1; |
233 return 1; |
234 } |
234 } |
235 } |
235 } |
236 } |
236 } |
509 } else { |
509 } else { |
510 return -1; |
510 return -1; |
511 } |
511 } |
512 } |
512 } |
513 |
513 |
514 sstr_t scstrdup(scstr_t s) { |
514 sstr_t ucx_strdup(scstr_t s) { |
515 return sstrdup_a(ucx_default_allocator(), s); |
515 return sstrdup_a(ucx_default_allocator(), s); |
516 } |
516 } |
517 |
517 |
518 sstr_t scstrdup_a(UcxAllocator *allocator, scstr_t s) { |
518 sstr_t ucx_strdup_a(UcxAllocator *allocator, scstr_t s) { |
519 sstr_t newstring; |
519 sstr_t newstring; |
520 newstring.ptr = (char*)almalloc(allocator, s.length + 1); |
520 newstring.ptr = (char*)almalloc(allocator, s.length + 1); |
521 if (newstring.ptr) { |
521 if (newstring.ptr) { |
522 newstring.length = s.length; |
522 newstring.length = s.length; |
523 newstring.ptr[newstring.length] = 0; |
523 newstring.ptr[newstring.length] = 0; |