Explorar el Código

Organize memory allocation

Only free memory that are dynamically allocated.
master
TheoryOfNekomata hace 1 año
padre
commit
49d7937d05
Se han modificado 4 ficheros con 10 adiciones y 11 borrados
  1. +1
    -1
      src/packages/compat/IZ_windows.h
  2. +0
    -1
      src/packages/game/data/IZ_list.c
  3. +8
    -9
      src/packages/game/data/data.test.c
  4. +1
    -0
      src/packages/stdinc/IZ_stdlib.c

+ 1
- 1
src/packages/compat/IZ_windows.h Ver fichero

@@ -3,7 +3,7 @@

#ifndef IZ_WINDOWS
typedef int errno_t;
typedef unsigned int rsize_t;
typedef size_t rsize_t;
#else
#include <io.h>
#include <SDL_syswm.h>


+ 0
- 1
src/packages/game/data/IZ_list.c Ver fichero

@@ -83,7 +83,6 @@ void IZ_ListTeardown(IZ_List* list) {
while (list->length > 0) {
IZ_ListDoDeleteNode(list->root);
}
IZ_free(list);
}

/**


+ 8
- 9
src/packages/game/data/data.test.c Ver fichero

@@ -64,7 +64,7 @@ spec("data") {
}

it("removes all nodes from the list") {
mock_set_expected_calls(IZ_free, 4);
mock_set_expected_calls(IZ_free, 3);
IZ_ListTeardown(&list);
unsigned int expected_calls = mock_get_expected_calls(IZ_free);
unsigned int actual_calls = mock_get_actual_calls(IZ_free);
@@ -87,14 +87,13 @@ spec("data") {
before_each() {
IZ_ListInitialize(&list2);
static u64 existing_value = 69420u;
static IZ_ListNode existing_node = {
.list = NULL,
.previous = NULL,
.value = &existing_value,
.next = NULL,
};
list2.root = &existing_node;
existing_node.list = &list2;
static IZ_ListNode* existing_node;
existing_node = IZ_malloc(sizeof(IZ_ListNode));
existing_node->list = &list2;
existing_node->previous = NULL;
existing_node->value = &existing_value;
existing_node->next = NULL;
list2.root = existing_node;
list2.length = 1;
}



+ 1
- 0
src/packages/stdinc/IZ_stdlib.c Ver fichero

@@ -10,4 +10,5 @@ void* IZ_calloc(unsigned int count, size_t size) {

void IZ_free(void* p) {
SDL_free(p);
p = NULL;
}

Cargando…
Cancelar
Guardar