aboutsummaryrefslogtreecommitdiff
path: root/src/alloc.c
blob: 90682b5f9a623f4dc49ee20b4596b8ab62d862fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "../include/alloc.h"
#include <stdlib.h>
#include <stdio.h>

void* mgui_alloc(size_t size) {
    void *mem = malloc(size);
    if(!mem) {
        fprintf(stderr, "mgui error: mgui_alloc failed to allocate %zu bytes\n", size);
        abort();
    }
    return mem;
}

void* mgui_realloc(void *mem, size_t new_size) {
    void *new_mem = realloc(mem, new_size);
    if(!new_mem) {
        fprintf(stderr, "mgui error: mgui_realloc failed to reallocate %p to %zu bytes\n", mem, new_size);
        abort();
    }
    return new_mem;
}

void mgui_free(void *mem) {
    free(mem);
}