some bugs in memory allocation

This commit is contained in:
Gregory Wells
2025-06-12 12:26:36 -04:00
parent e0869b9ed3
commit dabd88465f
10 changed files with 120 additions and 107 deletions

View File

@@ -1,13 +1,11 @@
#include "gryphn_command_buffer.h"
#include "core/gryphn_platform_functions.h"
#include "stdio.h"
gnReturnCode gnCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* buffers, uint32_t count, gnCommandPoolHandle commandPool) {
for (int i = 0; i < count; i++) {
buffers[i] = malloc(sizeof(struct gnCommandBuffer_t));
buffers[i]->commandPool = commandPool;
}
printf("Created the graphics pipeline: %p\n", commandPool->commandFunctions->_gnCommandBindGraphicsPipeline);
return commandPool->commandFunctions->_gnCommandPoolAllocateCommandBuffers(buffers, count, commandPool);
}

View File

@@ -7,5 +7,5 @@ gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const struct gnDebugge
return GN_SUCCESS;
}
void gnDestroyDebugger(gnDebuggerHandle debugger) {
free(debugger);
// free(debugger);
}

View File

@@ -6,9 +6,9 @@
#include "stdio.h"
gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInstanceInfo_t info) {
*instanceHandlePtr = malloc(sizeof(struct gnInstance_t));
gnInstanceHandle instance = *instanceHandlePtr;
instance->debugger = NULL;
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
instance->loadDeviceFunctions = gnFalse;
@@ -22,8 +22,6 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInst
return instance->functions->_gnCreateInstance(instance, info);
}
void gnInstanceAttachDebugger(gnInstanceHandle instance, struct gnDebugger_t *debugger) {
if (instance->debugger != NULL) {
gnDebuggerSetErrorMessage(debugger, (gnMessageData){
.message = gnCreateString("Debugger already attached to instance")
@@ -39,15 +37,11 @@ void gnInstanceAttachDebugger(gnInstanceHandle instance, struct gnDebugger_t *de
}
}
#include "stdio.h"
void gnDestroyInstance(gnInstanceHandle instance) {
if (instance->debugger) {
instance->functions->_gnDestroyDebugger(instance->debugger);
}
if (instance->debugger) instance->functions->_gnDestroyDebugger(instance->debugger);
instance->functions->_gnDestroyInstance(instance);
}
void gnInstanceReleaseDebugger(gnInstanceHandle instance) {
instance->debugger = NULL;
free(instance);
}