diff options
Diffstat (limited to 'src/caret.c')
-rw-r--r-- | src/caret.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/caret.c b/src/caret.c index 02d5b94b..2d7e9a8e 100644 --- a/src/caret.c +++ b/src/caret.c @@ -3,7 +3,10 @@ #include "caret.h" +#include "memory.h" + #include "serd/caret.h" +#include "serd/memory.h" #include <assert.h> #include <stdbool.h> @@ -11,13 +14,15 @@ #include <string.h> SerdCaret* -serd_caret_new(const SerdNode* const document, +serd_caret_new(SerdAllocator* const allocator, + const SerdNode* const document, const unsigned line, const unsigned column) { assert(document); - SerdCaret* caret = (SerdCaret*)malloc(sizeof(SerdCaret)); + SerdCaret* const caret = + (SerdCaret*)serd_amalloc(allocator, sizeof(SerdCaret)); if (caret) { caret->document = document; @@ -29,21 +34,26 @@ serd_caret_new(const SerdNode* const document, } SerdCaret* -serd_caret_copy(const SerdCaret* const caret) +serd_caret_copy(SerdAllocator* const allocator, const SerdCaret* const caret) { if (!caret) { return NULL; } - SerdCaret* copy = (SerdCaret*)malloc(sizeof(SerdCaret)); - memcpy(copy, caret, sizeof(SerdCaret)); + SerdCaret* const copy = + (SerdCaret*)serd_amalloc(allocator, sizeof(SerdCaret)); + + if (copy) { + memcpy(copy, caret, sizeof(SerdCaret)); + } + return copy; } void -serd_caret_free(SerdCaret* const caret) +serd_caret_free(SerdAllocator* const allocator, SerdCaret* const caret) { - free(caret); + serd_afree(allocator, caret); } bool |