#include "memory.h"

#include "logger.h"

#include <malloc.h>
#include <memory.h>

void *bzAlloc(size_t numBytes) {
    void *ptr = malloc(numBytes);
    bzLoggerOnlyLog(BZ_LOG_TRACE, "Allocating address: %p (num bytes: %llu)", ptr, numBytes);
    return ptr;
}
void bzFree(void *ptr) {
    bzLoggerOnlyLog(BZ_LOG_TRACE, "Freeing address: %p", ptr);
    free(ptr);
}
void *bzCalloc(size_t numBytes, size_t count) {
    void *ptr = calloc(numBytes, count);
    bzLoggerOnlyLog(BZ_LOG_TRACE, "Allocating address: %p (num bytes: %llu)", ptr, numBytes * count);
    return ptr;
}
void *bzResize(void *ptr, size_t newSize) {
    void *outPtr = realloc(ptr, newSize);
    bzLoggerOnlyLog(BZ_LOG_TRACE, "Resizing address: %p (%p) to %llu bytes.", outPtr, ptr, newSize);
    return outPtr;
}

void *bzMemSet(void *ptr, int value, size_t numBytes) {
    return memset(ptr, value, numBytes);
}
void *bzMemMove(void *dst, void *src, size_t numBytes) {
    return memmove(dst, src, numBytes);
}
void *bzMemCpy(void *dst, void *src, size_t numBytes) {
    return memcpy(dst, src, numBytes);
}
