papermario/src/heap.c
Ethan Roseman a37f30dc94
Modern gcc + shiftability work (#942)
* wip changes for modern gcc

* more

* wip

* blah

* Define explicit size for symbol

* Clean up evt_handle_exec1

* wip

* .

* fixes & VLA macro

* VLA innit

* wipz

* Fix potential UB

* meowp

* meowp2

* fixies

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "e1f0b17917"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "e1f0b17917"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "aa416e4"

* fixules

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "3ba3277e57"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "3ba3277e57"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "aa416e4"

* more shiftability + symbols work

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "02879e52a7"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "02879e52a7"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "aa416e4"

* more

* revert bss changes for now, new heaps overlay for aligning stuff to 0x1000 (not sure how necessary that is, so maybe will revert later on)

* 'fixing' jp shift build

* more

* more syms

* more progress

* more

* ididid

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "de54da38f5"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "de54da38f5"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "aa416e4"

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "a27dc436a6"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "a27dc436a6"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "aa416e4"

* blah

* stuff's broken, but at least it's maybe cleaner

* modern gcc back

* revert

* shifting all overlays - works so far

* progs

* another

* modern gcc flag, re-enabled all ifdef shift stuff

* fixies

* progress

* fixes, matching build

* heaps3 overlay and some symbol names

* changies

* PR comments & cleanup
2023-02-14 22:14:14 +09:00

72 lines
1.6 KiB
C

#include "common.h"
extern HeapNode heap_generalHead;
extern HeapNode heap_collisionHead;
HeapNode* general_heap_create(void) {
return _heap_create(&heap_generalHead, GENERAL_HEAP_SIZE);
}
void* general_heap_malloc(s32 size) {
return _heap_malloc(&heap_generalHead, size);
}
void* general_heap_malloc_tail(s32 size) {
return _heap_malloc_tail(&heap_generalHead, size);
}
s32 general_heap_free(void* data) {
return _heap_free(&heap_generalHead, data);
}
s32 battle_heap_create(void) {
if ((s32)_heap_create(&heap_battleHead, BATTLE_HEAP_SIZE) == -1) {
return -1;
} else {
return 0;
}
}
s32 func_8002ACDC(void) {
return 0;
}
void* heap_malloc(s32 size) {
if (!gGameStatusPtr->isBattle) {
return general_heap_malloc(size);
} else {
return _heap_malloc(&heap_battleHead, size);
}
}
s32 heap_free(void* data) {
if (gGameStatusPtr->isBattle) {
return _heap_free(&heap_battleHead, data);
} else {
return general_heap_free(data);
}
}
s32 collision_heap_create(void) {
if ((s32)_heap_create(&heap_collisionHead, COLLISION_HEAP_SIZE) == -1) {
return -1;
}
return 0;
}
void* collision_heap_malloc(s32 size) {
if (!gGameStatusPtr->isBattle) {
return _heap_malloc(&heap_collisionHead, size);
} else {
return _heap_malloc(&heap_battleHead, size);
}
}
s32 collision_heap_free(void* data) {
if (gGameStatusPtr->isBattle) {
return _heap_free(&heap_battleHead, data);
} else {
return _heap_free(&heap_collisionHead, data);
}
}