| 1318:12fa1d37fe48 | 1319:aa1f580f8f59 |
|---|---|
| 63 return (cxstring) {cstring, length}; | 63 return (cxstring) {cstring, length}; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void cx_strfree(cxmutstr *str) { | 66 void cx_strfree(cxmutstr *str) { |
| 67 if (str == NULL) return; | 67 if (str == NULL) return; |
| 68 cxFree(cxDefaultAllocator, str->ptr); | 68 cxFreeDefault(str->ptr); |
| 69 str->ptr = NULL; | 69 str->ptr = NULL; |
| 70 str->length = 0; | 70 str->length = 0; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void cx_strfree_a( | 73 void cx_strfree_a( |
| 285 | 285 |
| 286 // check needle length and use appropriate prefix table | 286 // check needle length and use appropriate prefix table |
| 287 // if the pattern exceeds static prefix table, allocate on the heap | 287 // if the pattern exceeds static prefix table, allocate on the heap |
| 288 const bool useheap = needle.length >= CX_STRSTR_SBO_SIZE; | 288 const bool useheap = needle.length >= CX_STRSTR_SBO_SIZE; |
| 289 register size_t *ptable = useheap | 289 register size_t *ptable = useheap |
| 290 ? cxCalloc(cxDefaultAllocator, needle.length + 1, sizeof(size_t)) | 290 ? cxCallocDefault(needle.length + 1, sizeof(size_t)) |
| 291 : s_prefix_table; | 291 : s_prefix_table; |
| 292 | 292 |
| 293 // keep counter in registers | 293 // keep counter in registers |
| 294 register size_t i, j; | 294 register size_t i, j; |
| 295 | 295 |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 | 326 |
| 327 // if prefix table was allocated on the heap, free it | 327 // if prefix table was allocated on the heap, free it |
| 328 if (useheap) { | 328 if (useheap) { |
| 329 cxFree(cxDefaultAllocator, ptable); | 329 cxFreeDefault(ptable); |
| 330 } | 330 } |
| 331 | 331 |
| 332 return result; | 332 return result; |
| 333 } | 333 } |
| 334 | 334 |