Remove copy_alloc functions
This commit is contained in:
parent
12e8515b27
commit
509d6c912f
@ -182,53 +182,6 @@ RETURN_STR8_CONCAT:
|
||||
return output;
|
||||
}
|
||||
|
||||
Str8 *wapp_str8_alloc_copy_cstr(const Allocator *allocator, Str8 *dst, const char *src) {
|
||||
wapp_debug_assert(allocator != NULL && dst != NULL && src != NULL, "`allocator`, `dst` and `src` should not be NULL");
|
||||
|
||||
Str8 *output = NULL;
|
||||
u64 size = strlen(src);
|
||||
if (size <= dst->capacity) {
|
||||
output = dst;
|
||||
goto SOURCE_CSTRING_STR8_COPY;
|
||||
}
|
||||
|
||||
u64 capacity = dst->capacity + size;
|
||||
|
||||
output = wapp_str8_alloc_buf(allocator, capacity);
|
||||
if (!output) {
|
||||
goto RETURN_CSTRING_STR8_COPY;
|
||||
}
|
||||
|
||||
SOURCE_CSTRING_STR8_COPY:
|
||||
wapp_str8_copy_cstr_capped(output, src);
|
||||
|
||||
RETURN_CSTRING_STR8_COPY:
|
||||
return output;
|
||||
}
|
||||
|
||||
Str8 *wapp_str8_alloc_copy_str8(const Allocator *allocator, Str8 *dst, Str8RO *src) {
|
||||
wapp_debug_assert(allocator != NULL && dst != NULL && src != NULL, "`allocator`, `dst` and `src` should not be NULL");
|
||||
|
||||
Str8 *output = NULL;
|
||||
if (src->size <= dst->capacity) {
|
||||
output = dst;
|
||||
goto SOURCE_STRING_STR8_COPY;
|
||||
}
|
||||
|
||||
u64 capacity = dst->capacity + src->size;
|
||||
|
||||
output = wapp_str8_alloc_buf(allocator, capacity);
|
||||
if (!output) {
|
||||
goto RETURN_STRING_STR8_COPY;
|
||||
}
|
||||
|
||||
SOURCE_STRING_STR8_COPY:
|
||||
wapp_str8_copy_str8_capped(output, src);
|
||||
|
||||
RETURN_STRING_STR8_COPY:
|
||||
return output;
|
||||
}
|
||||
|
||||
void wapp_str8_concat_capped(Str8 *dst, Str8RO *src) {
|
||||
wapp_debug_assert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL");
|
||||
|
||||
|
@ -79,8 +79,6 @@ Str8 *wapp_str8_alloc_cstr(const Allocator *allocator, const char *str);
|
||||
Str8 *wapp_str8_alloc_str8(const Allocator *allocator, Str8RO *str);
|
||||
Str8 *wapp_str8_alloc_substr(const Allocator *allocator, Str8RO *str, u64 start, u64 end);
|
||||
Str8 *wapp_str8_alloc_concat(const Allocator *allocator, Str8 *dst, Str8RO *src);
|
||||
Str8 *wapp_str8_alloc_copy_cstr(const Allocator *allocator, Str8 *dst, const char *src);
|
||||
Str8 *wapp_str8_alloc_copy_str8(const Allocator *allocator, Str8 *dst, Str8RO *src);
|
||||
// Only needed for allocators like malloc where each allocation has to be freed on its own.
|
||||
// No need to use it for allocators like Arena.
|
||||
void wapp_str8_dealloc_buf(const Allocator *allocator, Str8 **str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user