git / brickware / marrow.git - main

(4 seconds ago)commit 81d366f: removed janky one time list, and replaced with generic vector implementation

tree / lalloc.c

lalloc.c

raw

/***
 * lalloc.c
 */

#include <stdint.h>
#include <stdlib.h>

#include "./allocator.h"
#include "./vector.h"


void *
lalloc(const struct allocator alloc, void *ptr, const size_t num, const size_t size)
{
    void *result;

    result = 0x00;
    if ((num) && (size)) {
        if (0x00 == ptr) {
            result = alloc.alloc(num, size);
        } else {
            result = alloc.realloc(ptr, num, size);
            if (0x00 == result) {
                alloc.free(ptr);
            }
        }
    }

    return (result);
}