diff options
Diffstat (limited to 'src/string_view.c')
-rw-r--r-- | src/string_view.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/string_view.c b/src/string_view.c new file mode 100644 index 0000000..9d98258 --- /dev/null +++ b/src/string_view.c @@ -0,0 +1,18 @@ +// Copyright 2007-2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#include "zix/string_view.h" +#include "zix/allocator.h" + +#include <string.h> + +char* +zix_string_view_copy(ZixAllocator* const allocator, const ZixStringView view) +{ + char* const copy = (char*)zix_malloc(allocator, view.length + 1U); + if (copy) { + memcpy(copy, view.data, view.length); + copy[view.length] = '\0'; + } + return copy; +} |