diff options
Diffstat (limited to 'js/scripting-lang/baba-yaga-c/src/memory.c')
-rw-r--r-- | js/scripting-lang/baba-yaga-c/src/memory.c | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/js/scripting-lang/baba-yaga-c/src/memory.c b/js/scripting-lang/baba-yaga-c/src/memory.c deleted file mode 100644 index f6bca85..0000000 --- a/js/scripting-lang/baba-yaga-c/src/memory.c +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file memory.c - * @brief Memory management implementation for Baba Yaga - * @author eli_oat - * @version 0.0.1 - * @date 2025 - * - * This file implements memory management utilities for the Baba Yaga language. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "baba_yaga.h" - -/* ============================================================================ - * Memory Management Functions - * ============================================================================ */ - -/* TODO: Implement memory management functions */ - -void* memory_alloc(size_t size) { - void* ptr = malloc(size); - if (ptr == NULL) { - /* TODO: Handle allocation failure */ - fprintf(stderr, "Memory allocation failed: %zu bytes\n", size); - } - return ptr; -} - -void* memory_realloc(void* ptr, size_t size) { - void* new_ptr = realloc(ptr, size); - if (new_ptr == NULL) { - /* TODO: Handle reallocation failure */ - fprintf(stderr, "Memory reallocation failed: %zu bytes\n", size); - } - return new_ptr; -} - -void memory_free(void* ptr) { - if (ptr != NULL) { - free(ptr); - } -} - -char* memory_strdup(const char* str) { - if (str == NULL) { - return NULL; - } - return strdup(str); -} - -char* memory_strndup(const char* str, size_t n) { - if (str == NULL) { - return NULL; - } - - char* new_str = memory_alloc(n + 1); - if (new_str == NULL) { - return NULL; - } - - strncpy(new_str, str, n); - new_str[n] = '\0'; - - return new_str; -} |