git / brickware / marrow.git - main

(45 minutes ago)commit 7790c99: Meh. Halfway vector implementation. Not happy with the name

tree / defalloc.c

defalloc.c

raw

#include <stdlib.h>

#include "./allocator.h"


static inline void *
__calloc2(const size_t num, const size_t size);

static inline void *
__realloc3(void *ptr, const size_t num, const size_t size);

static inline void
__free1(void *ptr);


static inline void *
__calloc2(const size_t num, const size_t size)
{
    return calloc(num, size);
}

static inline void *
__realloc3(void *ptr, const size_t num, const size_t size)
{
    if (0x00 != ptr) {
        return realloc(ptr, num * size);
    }

    return __calloc2(num, size);
}

static inline void
__free1(void *ptr)
{
    if (0x00 != ptr) {
        free(ptr);
    }
}


const struct allocator defalloc = {
    .alloc = __calloc2,
    .realloc = __realloc3,
    .free = __free1
};