Pārlūkot izejas kodu

Organize memory allocation

Only free memory that are dynamically allocated.
master
TheoryOfNekomata pirms 1 gada
vecāks
revīzija
49d7937d05
4 mainītis faili ar 10 papildinājumiem un 11 dzēšanām
  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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

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

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

Notiek ielāde…
Atcelt
Saglabāt