From 564292b03ee62264d9b135db382c7e6bed5bf655 Mon Sep 17 00:00:00 2001 From: arthur barraux Date: Wed, 3 Jun 2026 09:20:00 +0200 Subject: [PATCH] linux lib compatibility --- include/utils.h | 16 -------------- main.c | 15 +++++++------- meson.build | 3 +-- src/append_buffer.c | 5 ++--- src/buffer.c | 21 +++++++++---------- src/builtins.c | 30 +++++++++++++-------------- src/completion.c | 45 +++++++++++++--------------------------- src/editor_op.c | 5 ++--- src/file_io.c | 12 +++++------ src/init.c | 15 +++++++------- src/input.c | 11 +++++----- src/output.c | 5 +---- src/split_screen.c | 16 +++++--------- src/syntax_highlighter.c | 3 +-- src/terminal.c | 2 +- src/utils.c | 37 --------------------------------- 16 files changed, 75 insertions(+), 166 deletions(-) delete mode 100644 include/utils.h delete mode 100644 src/utils.c diff --git a/include/utils.h b/include/utils.h deleted file mode 100644 index 2721f72..0000000 --- a/include/utils.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// Created by Giorgio on 28/05/2026. -// - -#ifndef BELUGA_UTILS_H -#define BELUGA_UTILS_H -#include - -extern int beluga_alloc_counter; - - -void * bAlloc(size_t size); -void * bRealloc(void * ptr, size_t size); -void * bFree(void * ptr); - -#endif //BELUGA_UTILS_H diff --git a/main.c b/main.c index f263dd8..c45634c 100644 --- a/main.c +++ b/main.c @@ -11,8 +11,6 @@ #include -#include "include/utils.h" - #include "include/buffer.h" #include "include/split_screen.h" #include @@ -26,13 +24,15 @@ #include "include/completion.h" #include -#include "include/utils.h" struct editorConfig E; int main(int argc, char *argv[]) { - char * splash_screen = bAlloc(sizeof(char) * 512); + char * splash_screen = strdup(getenv("HOME")); + int home_path_len = (int) strlen(splash_screen); + char * splash_screen_relative_path = strdup("/.beluga/assets/beluga.txt"); + int splash_screen_relative_path_len = (int) strlen(splash_screen_relative_path); signal(SIGPIPE, SIG_IGN); // don't die on broken pipe, just get EPIPE from write() @@ -41,8 +41,9 @@ int main(int argc, char *argv[]) { EditorPane *active = splitScreenGetActivePane(); struct buffer_t *buf; - strcat(splash_screen, getenv("HOME")); + splash_screen = realloc(splash_screen, sizeof(char) * (home_path_len + splash_screen_relative_path_len + 1)); strcat(splash_screen, "/.beluga/assets/beluga.txt"); + free(splash_screen_relative_path); appDebug("splash : %s\n", splash_screen); active->buffer_id = bufferCreate(splash_screen, READ_ONLY); @@ -59,12 +60,10 @@ int main(int argc, char *argv[]) { } - bFree(splash_screen); + free(splash_screen); editorSetStatusMessage("HELP: Ctrl-x Ctrl-s = save | Ctrl-x Ctrl-c = quit"); - appDebug("allocation : %d\n", beluga_alloc_counter); - while (1) { editorRefreshScreen(); editorProcessKeypress(); diff --git a/meson.build b/meson.build index 7071c96..0852e90 100644 --- a/meson.build +++ b/meson.build @@ -27,8 +27,7 @@ src_files = files( 'src/utf8.c', 'src/completion.c', 'src/lsp_ui.c', - 'src/cJSON.c', - 'src/utils.c' + 'src/cJSON.c' ) # Executable diff --git a/src/append_buffer.c b/src/append_buffer.c index 9695d6a..4b0d4e5 100644 --- a/src/append_buffer.c +++ b/src/append_buffer.c @@ -1,8 +1,7 @@ #include "../include/append_buffer.h" -#include "include/utils.h" void abAppend(struct abuf *ab, const char *s, int len) { - char *new = bRealloc(ab->b, ab->len + len); + char *new = realloc(ab->b, ab->len + len); if (new == NULL) { return; @@ -12,4 +11,4 @@ void abAppend(struct abuf *ab, const char *s, int len) { ab->len += len; } -void abFree(const struct abuf *ab) { bFree(ab->b); } +void abFree(const struct abuf *ab) { free(ab->b); } diff --git a/src/buffer.c b/src/buffer.c index 6fa5e9d..25fc73b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -17,7 +17,6 @@ #include "include/completion.h" #include "include/input.h" -#include "include/utils.h" /** @@ -82,7 +81,7 @@ int bufferCreate(const char* path, enum bufferStatus_e state) struct buffer_t* new_buf = &E.buffers[E.number_of_buffer]; new_buf->buffer_id = E.number_of_buffer; new_buf->filename = strdup(filename); - new_buf->fullname = bAlloc(1024 * sizeof(char)); + new_buf->fullname = malloc(1024 * sizeof(char)); realpath(path, new_buf->fullname); new_buf->path = dirname(new_buf->fullname); new_buf->type = FILE_BUFF; @@ -176,7 +175,7 @@ int bufferClose(int buffer_id) } // Free buffer resources - bFree(buf->filename); + free(buf->filename); buf->filename = NULL; buf->buffer_id = -1; @@ -312,7 +311,7 @@ void bufferFind(struct buffer_t* buf) break; } } - bFree(query); + free(query); } void bufferFindReverse(struct buffer_t* buf) @@ -335,14 +334,14 @@ void bufferFindReverse(struct buffer_t* buf) break; } } - bFree(query); + free(query); } void bufferInsertRow(struct buffer_t *buffer, int at, char *s, size_t len) { if (at < 0 || at > buffer->numrows) return; - row_t *tmp = bRealloc(buffer->row, sizeof(row_t) * (buffer->numrows + 1)); + row_t *tmp = realloc(buffer->row, sizeof(row_t) * (buffer->numrows + 1)); if (!tmp) return; buffer->row = tmp; @@ -355,7 +354,7 @@ void bufferInsertRow(struct buffer_t *buffer, int at, char *s, size_t len) { buffer->row[at].size = (int) len; buffer->row[at].cap = (int) len + 1; - buffer->row[at].chars = bAlloc(len + 1); + buffer->row[at].chars = malloc(len + 1); if (!buffer->row[at].chars) return; memcpy(buffer->row[at].chars, s, len); @@ -365,7 +364,7 @@ void bufferInsertRow(struct buffer_t *buffer, int at, char *s, size_t len) { buffer->dirty++; } -void bufferFreeRow(row_t *row) { bFree(row->chars); } +void bufferFreeRow(row_t *row) { free(row->chars); } /** * \fn editorRowInsertChar(erow *row, int at, int c) @@ -377,12 +376,12 @@ void bufferRowInsertBytes(struct buffer_t *buffer, row_t *row, int at, return; if (row->size + n + 1 > row->cap) { row->cap = (row->size + n + 1) * 2; - row->chars = bRealloc(row->chars, row->cap); + row->chars = realloc(row->chars, row->cap); } memmove(row->chars + at + n, row->chars + at, row->size - at); memcpy(row->chars + at, src, n); row->size += n; - row->chars = bRealloc(row->chars, row->size + 2); + row->chars = realloc(row->chars, row->size + 2); ++buffer->dirty; } @@ -446,7 +445,7 @@ void bufferDelBytes(void) int prev_char_count = editorRowCharCount(prev, prev->size); bufferRowInsertBytes(buf, prev, prev->size, r->chars, r->size); - bFree(r->chars); + free(r->chars); r->chars = NULL; memmove(&buf->row[buf->y], diff --git a/src/builtins.c b/src/builtins.c index 416e457..e81bee1 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -22,7 +22,6 @@ #include "include/completion.h" #include "include/init.h" -#include "include/utils.h" /** * @brief Finds a prefix configuration by name @@ -69,13 +68,13 @@ Lisp mapKey(Lisp args, LispError* e, LispContext ctx) // second argument const Lisp func = lisp_car(args); - memory_temp = bRealloc( + memory_temp = realloc( E.key_binds, ++E.number_of_keybinds * sizeof(struct keyBind_t)); E.key_binds = (struct keyBind_t*)memory_temp; if (!E.key_binds) editorQuit(args, e, ctx); E.key_binds[E.number_of_keybinds - 1].key_sequence = - (char*)bAlloc(50 * sizeof(char)); + (char*)malloc(50 * sizeof(char)); strncpy(E.key_binds[E.number_of_keybinds - 1].key_sequence, key_sequence, 50); @@ -137,27 +136,27 @@ Lisp moveCursor(Lisp args, LispError* e, LispContext ctx) void bFree_structs(void) { int i, j; - bFree(E.prefix); + free(E.prefix); for (i = 0; i < E.number_of_keybinds; ++i) { - bFree(E.key_binds[i].key_sequence); + free(E.key_binds[i].key_sequence); } - bFree(E.key_binds); + free(E.key_binds); // bFree layout - bFree(E.layout.panes); + free(E.layout.panes); // bFree buffers for (i = 0; i < E.number_of_buffer; ++i) { - bFree(E.buffers[i].filename); + free(E.buffers[i].filename); for (j = 0; j < E.buffers[i].numrows; ++j) { - bFree(E.buffers[i].row[j].chars); + free(E.buffers[i].row[j].chars); } - bFree(E.buffers[i].row); + free(E.buffers[i].row); } - bFree(E.init_file_path); + free(E.init_file_path); fclose(E.fd_init_file); } @@ -186,11 +185,10 @@ Lisp editorQuit(Lisp args, LispError* e, LispContext ctx) bFree_structs(); write(STDOUT_FILENO, "\x1b[2J", 4); write(STDOUT_FILENO, CURSOR_TOP_LEFT, 3); - disableRawMode(); lspShutdown(E.lsp_client); lisp_shutdown(E.ctx); deInitEditor(); - appDebug("Rest alloc %d\n", beluga_alloc_counter); + disableRawMode(); exit(0); } @@ -379,7 +377,7 @@ Lisp editorOpenFile(Lisp args, LispError* e, LispContext ctx) EditorPane* active = splitScreenGetActivePane(); active->buffer_id = bufferCreate(filename, READ_AND_WRITE); } - bFree(filename); + free(filename); return lisp_null(); } @@ -427,7 +425,7 @@ Lisp addPackage(Lisp args, LispError* e, LispContext ctx) lisp_eval(lisp_read_file(fd_package, &E.ctx_error, E.ctx), &E.ctx_error, E.ctx); fclose(fd_package); - bFree(package_dir); + free(package_dir); return lisp_null(); } @@ -558,7 +556,7 @@ Lisp editorSetPrefix(Lisp args, LispError* e, LispContext ctx) */ Lisp editorPrefix(Lisp args, LispError* e, LispContext ctx) { - E.prefix = (struct prefix_t*)bRealloc(E.prefix, (++(E.number_of_prefix) + 1) * + E.prefix = (struct prefix_t*)realloc(E.prefix, (++(E.number_of_prefix) + 1) * sizeof(struct prefix_t)); E.prefix[E.number_of_prefix].prefix_id = E.number_of_prefix; strncpy(E.prefix[E.number_of_prefix].prefix_name, lisp_string(lisp_car(args)), diff --git a/src/completion.c b/src/completion.c index 05acd14..25a670c 100644 --- a/src/completion.c +++ b/src/completion.c @@ -15,7 +15,6 @@ #include "include/lsp_ui.h" #include "include/split_screen.h" #include "include/terminal.h" -#include "include/utils.h" static void lsp_send(int fd, const char* json) { @@ -33,22 +32,6 @@ static void lsp_send(int fd, const char* json) fflush(stderr); } -static int lsp_uri_to_buffer_id(const char* uri) -{ - const char *path = uri; - if (strncmp(uri, "file://", 7) == 0) - path = uri + 7; - // path is now "/absolute/path" — realpath output matches this directly - - for (int i = 0; i < E.number_of_buffer; i++) { - if (E.buffers[i].filename == NULL) continue; - appDebug("[URI MATCH] comparing '%s' vs '%s'\n", E.buffers[i].fullname, path); - if (strcmp(E.buffers[i].fullname, path) == 0) - return E.buffers[i].buffer_id; - } - return -1; -} - static char* lsp_recv(int fd) { char header[1024]; @@ -74,14 +57,14 @@ static char* lsp_recv(int fd) if (content_length == 0) return NULL; - char* body = bAlloc(content_length + 1); + char* body = malloc(content_length + 1); int total = 0; while (total < content_length) { int n = read(fd, body + total, content_length - total); if (n <= 0) { - bFree(body); + free(body); return NULL; } total += n; @@ -251,7 +234,7 @@ static void* lsp_reader(void* arg) char* msg = lsp_recv(lsp->read_fd); if (!msg) break; // ← pipe closed or error, exit cleanly lsp_dispatch(lsp, msg); - bFree(msg); + free(msg); } return NULL; } @@ -382,7 +365,7 @@ static char* buffer_to_text(struct buffer_t* buf) int total = 0; for (int i = 0; i < buf->numrows; i++) total += buf->row[i].size + 1; // +1 for \n - char* text = bAlloc(total + 1); + char* text = malloc(total + 1); char* p = text; for (int i = 0; i < buf->numrows; i++) { @@ -428,8 +411,8 @@ void lspDidOpen(LspClient* lsp, struct buffer_t* buf) char* msg = cJSON_PrintUnformatted(root); lsp_send(lsp->write_fd, msg); - bFree(msg); - bFree(raw); + free(msg); + free(raw); cJSON_Delete(root); buf->b_lsp_open = 1; } @@ -466,8 +449,8 @@ void lspDidChange(LspClient* lsp, struct buffer_t* buf) char* msg = cJSON_PrintUnformatted(root); lsp_send(lsp->write_fd, msg); - bFree(msg); - bFree(raw); + free(msg); + free(raw); cJSON_Delete(root); } @@ -487,7 +470,7 @@ void lspDidClose(LspClient* lsp, struct buffer_t* buf) cJSON_AddItemToObject(root, "params", params); char* msg = cJSON_PrintUnformatted(root); lsp_send(lsp->write_fd, msg); - bFree(msg); + free(msg); cJSON_Delete(root); buf->b_lsp_open = 0; } @@ -531,7 +514,7 @@ void lspRequestCompletion(LspClient* lsp, struct buffer_t* buf, lsp_send(lsp->write_fd, msg); E.lsp_client->completion_requested = 1; cJSON_Delete(req); - bFree(msg); + free(msg); } void lspRequestDefinition(LspClient* lsp, struct buffer_t* buf, int line, int col) @@ -544,7 +527,7 @@ void lspRequestDefinition(LspClient* lsp, struct buffer_t* buf, int line, int co "\"position\":{\"line\":%d,\"character\":%d}}}", lsp->next_id++, buf->filename, line, col); lsp_send(lsp->write_fd, msg); - bFree(msg); + free(msg); } void lspShutdown(LspClient *lsp) @@ -567,7 +550,7 @@ void lspShutdown(LspClient *lsp) cJSON_AddNullToObject (req, "params"); char *msg = cJSON_PrintUnformatted(req); lsp_send(lsp->write_fd, msg); - bFree(msg); + free(msg); cJSON_Delete(req); // 3. Wait briefly for the shutdown response (2s timeout) @@ -577,7 +560,7 @@ void lspShutdown(LspClient *lsp) FD_SET(lsp->read_fd, &fds); if (select(lsp->read_fd + 1, &fds, NULL, NULL, &tv) > 0) { char *resp = lsp_recv(lsp->read_fd); - bFree(resp); + free(resp); } // 4. Send exit notification @@ -607,5 +590,5 @@ void lspShutdown(LspClient *lsp) // 10. Reap the clangd process waitpid(lsp->pid, NULL, 0); - bFree(lsp); + free(lsp); } \ No newline at end of file diff --git a/src/editor_op.c b/src/editor_op.c index e86a3c1..345a2e5 100644 --- a/src/editor_op.c +++ b/src/editor_op.c @@ -8,7 +8,6 @@ #include "../include/split_screen.h" #include "../include/terminal.h" #include "../include/utf8.h" -#include "include/utils.h" extern struct editorConfig E; @@ -86,13 +85,13 @@ char *editorGetClipboard(void) { size_t cap = 4096; size_t len = 0; - char *buf = bAlloc(cap); + char *buf = malloc(cap); int c; while ((c = fgetc(pipe)) != EOF) { if (len + 1 >= cap) { cap *= 2; - buf = bRealloc(buf, cap); + buf = realloc(buf, cap); } buf[len++] = (char)c; } diff --git a/src/file_io.c b/src/file_io.c index 4a36b56..8b08933 100644 --- a/src/file_io.c +++ b/src/file_io.c @@ -13,7 +13,6 @@ #include "../include/data.h" #include "../include/split_screen.h" #include "../include/row_op.h" -#include <_string.h> #include #include #include @@ -21,7 +20,6 @@ #include #include -#include "../include/utils.h" /** * @brief Closes the current file and resets editor state @@ -37,13 +35,13 @@ void editorCloseFile(void) { active->x_offset = 0; active->y_offset = 0; for (int i = 0; i < buf->numrows; ++i) { - bFree(buf->row[i].chars); + free(buf->row[i].chars); } buf->numrows = 0; - bFree(buf->row); + free(buf->row); buf->row = NULL; buf->dirty = 0; - bFree(buf->filename); + free(buf->filename); buf->filename = NULL; E.status_msg[0] = '\0'; E.status_msg_time = 0; @@ -86,10 +84,10 @@ void editorOpen(struct buffer_t* buffer) { } appDebug("line %s\n", line); bufferInsertRow(buffer, buffer->numrows, line, line_len); - bFree(line); + free(line); line = NULL; } - bFree(line); + free(line); fclose(fp); E.dirty = 0; } diff --git a/src/init.c b/src/init.c index b1d1821..6d9ac13 100644 --- a/src/init.c +++ b/src/init.c @@ -11,7 +11,6 @@ #define LISP_IMPLEMENTATION #include "../include/lisp.h" #include "../include/lisp_lib.h" -#include "include/utils.h" struct editorConfig; @@ -133,12 +132,12 @@ void initEditor() { E.number_of_keybinds = 0; E.number_of_prefix = 0; // General prefix is 0 (no prefix) - E.prefix = (struct prefix_t *)bAlloc(sizeof(struct prefix_t)); + E.prefix = (struct prefix_t *)malloc(sizeof(struct prefix_t)); E.prefix[0].prefix_id = 0; strncpy(E.prefix[0].prefix_name, "no-prefix", 64); E.prefix_state = 0; - E.lsp_client = (LspClient*)bAlloc(sizeof(LspClient)); + E.lsp_client = (LspClient*)malloc(sizeof(LspClient)); E.lsp_client->state = LSP_SHUTDOWN; initConfig(); @@ -161,13 +160,13 @@ void initEditor() { void deInitEditor() { freeScreenLayout(&E.layout); - bFree(E.lsp_client); - bFree(E.status_msg); - bFree(E.init_file_path); - bFree(E.key_binds); + free(E.lsp_client); + free(E.status_msg); + free(E.init_file_path); + free(E.key_binds); for (int i = 0; i < E.number_of_keybinds; i++) { - bFree(E.key_binds[i].key_sequence); + free(E.key_binds[i].key_sequence); } } diff --git a/src/input.c b/src/input.c index 7d1c414..11cf34d 100644 --- a/src/input.c +++ b/src/input.c @@ -16,7 +16,6 @@ #include "include/terminal.h" #include "include/utf8.h" -#include "include/utils.h" /** * @file input.c @@ -91,7 +90,7 @@ const char *fileCompletion(const char *path) { // Cleanup when no more entries closedir(dir); dir = NULL; - bFree(entry); + free(entry); appDebug("[FILE COMP] no entries\n"); return strdup(path); } @@ -113,7 +112,7 @@ const char *fileCompletion(const char *path) { char *editorPrompt(char *prompt, char *placeHolder, char bPathMode) { size_t buf_size = 256; appDebug("[FILE COMP] %s %d\n", placeHolder, strlen(placeHolder)); - char *buf = bAlloc(buf_size); + char *buf = malloc(buf_size); size_t buf_len = 0; int c = 0; buf[0] = '\0'; @@ -130,7 +129,7 @@ char *editorPrompt(char *prompt, char *placeHolder, char bPathMode) { } } else if (c == ESCAPE) { editorSetStatusMessage(""); - bFree(buf); + free(buf); return NULL; } else if (c == '\r') { if (buf_len != 0) { @@ -152,14 +151,14 @@ char *editorPrompt(char *prompt, char *placeHolder, char bPathMode) { memset(buf, 0, 256); char *buf_complete = (char *)fileCompletion(path); strcpy(buf, buf_complete); - bFree(buf_complete); + free(buf_complete); buf_len = strlen(buf); buf[buf_len] = '\0'; } else if (!iscntrl(c) && c < 256) { if (buf_len == buf_size - 1) { buf_size *= 2; - buf = bRealloc(buf, buf_size); + buf = realloc(buf, buf_size); } buf[buf_len++] = (char)c; buf[buf_len] = '\0'; diff --git a/src/output.c b/src/output.c index 8d72d3b..29dedc6 100644 --- a/src/output.c +++ b/src/output.c @@ -21,9 +21,6 @@ #include #include -#include "include/completion.h" -#include "include/utils.h" - /** * @brief Renders a single pane with its buffer content */ @@ -85,7 +82,7 @@ static void editorDrawPane(struct abuf* ab, EditorPane* pane) // Print only up to pane width abAppend(ab, highlighted, byte_len_to_print); - bFree(highlighted); + free(highlighted); } else { diff --git a/src/split_screen.c b/src/split_screen.c index 6a1d2c2..51228a6 100644 --- a/src/split_screen.c +++ b/src/split_screen.c @@ -9,7 +9,6 @@ #include #include -#include "include/utils.h" extern struct editorConfig E; @@ -21,7 +20,7 @@ void splitScreenInit(void) { E.layout.num_panes = 1; E.layout.active_pane = 0; - E.layout.panes = bAlloc(sizeof(EditorPane) * 2); + E.layout.panes = malloc(sizeof(EditorPane) * 2); // Initialize single fullscreen pane E.layout.panes[0].buffer_id = -1; // No buffer for now @@ -51,7 +50,7 @@ int splitScreenVertical(int buffer_id_left, int buffer_id_right) { } // bReallocate panes array - E.layout.panes = bRealloc(E.layout.panes, sizeof(EditorPane) * 2); + E.layout.panes = realloc(E.layout.panes, sizeof(EditorPane) * 2); E.layout.mode = SPLIT_VERTICAL; E.layout.num_panes = 2; E.layout.active_pane = 0; @@ -102,7 +101,7 @@ int splitScreenHorizontal(int buffer_id_top, int buffer_id_bottom) { } // bReallocate panes array - E.layout.panes = bRealloc(E.layout.panes, sizeof(EditorPane) * 2); + E.layout.panes = realloc(E.layout.panes, sizeof(EditorPane) * 2); E.layout.mode = SPLIT_HORIZONTAL; E.layout.num_panes = 2; E.layout.active_pane = 0; @@ -221,15 +220,10 @@ EditorPane *splitScreenGetActivePane(void) { void freeScreenLayout(ScreenLayout *layout) { - while (--E.layout.num_panes >= 0) - { - bFree(&E.layout.panes); - } - - bFree(&E.layout); + free(layout->panes); } void freePane(EditorPane *pane) { - bFree(pane); + free(pane); } diff --git a/src/syntax_highlighter.c b/src/syntax_highlighter.c index 52e062a..c751094 100644 --- a/src/syntax_highlighter.c +++ b/src/syntax_highlighter.c @@ -5,7 +5,6 @@ #include #include -#include "include/utils.h" extern struct editorConfig E; @@ -113,7 +112,7 @@ char *highlight_line(const char *line, int *length) { // Allocate generously based on line length to avoid overflow. int line_len = strlen(line); int buf_size = line_len * 32 + 256; - char *result = bAlloc(buf_size); + char *result = malloc(buf_size); int result_pos = 0; int i = 0; diff --git a/src/terminal.c b/src/terminal.c index ed0fa8d..2d4afd2 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -12,7 +12,7 @@ #include "../include/buffer.h" #include "../include/split_screen.h" -#include "include/utf8.h" +#include "../include/utf8.h" void die(const char* s) { diff --git a/src/utils.c b/src/utils.c deleted file mode 100644 index c946fb7..0000000 --- a/src/utils.c +++ /dev/null @@ -1,37 +0,0 @@ -// -// Created by Giorgio on 28/05/2026. -// - -#include "../include/utils.h" - -#include - -int beluga_alloc_counter = 0; - -void * bAlloc(size_t size) -{ - void * result = malloc(size); - if (!result) - return NULL; - beluga_alloc_counter++; - return result; -} - -void * bRealloc(void * ptr, size_t size) -{ - void * result = realloc(ptr, size); - if (!result) - return NULL; - beluga_alloc_counter++; - return result; -} - -void * bFree(void * ptr) -{ - if (ptr) - { - free(ptr); - beluga_alloc_counter--; - } - return NULL; -}