diff options
Diffstat (limited to 'src/cursor.c')
-rw-r--r-- | src/cursor.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/cursor.c b/src/cursor.c index 1a94142e..e3d7e35f 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -16,6 +16,7 @@ #include "cursor.h" +#include "memory.h" #include "model.h" #include "node.h" @@ -25,7 +26,6 @@ #include <assert.h> #include <stdbool.h> -#include <stdlib.h> #include <string.h> static inline bool @@ -132,14 +132,19 @@ serd_cursor_make(const SerdModel* const model, } SerdCursor* -serd_cursor_copy(const SerdCursor* const cursor) +serd_cursor_copy(SerdAllocator* const allocator, const SerdCursor* const cursor) { if (!cursor) { return NULL; } - SerdCursor* const copy = (SerdCursor* const)malloc(sizeof(SerdCursor)); - memcpy(copy, cursor, sizeof(SerdCursor)); + SerdCursor* const copy = + (SerdCursor* const)serd_amalloc(allocator, sizeof(SerdCursor)); + + if (copy) { + memcpy(copy, cursor, sizeof(SerdCursor)); + } + return copy; } @@ -223,5 +228,7 @@ serd_cursor_equals(const SerdCursor* const lhs, const SerdCursor* const rhs) void serd_cursor_free(SerdCursor* const cursor) { - free(cursor); + if (cursor) { + serd_afree(cursor->model->allocator, cursor); + } } |