mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-04 19:25:43 -04:00
Isolate JKRHeap operator overloads
Fixes #25 This isolates the JKRHeap operator new/delete overloads. Every single new/delete site in the code has been replaced with a macro. Sadly for new[] and delete[] we have to keep global operators. The global new[] just allocates into malloc() however, and delete[] goes into free() if it's not in a JKRHeap. So that's fine.
This commit is contained in:
+22
-22
@@ -182,7 +182,7 @@ int dMeter2_c::_create() {
|
||||
field_0x1ac = dMeter2Info_isUseButton(16);
|
||||
field_0x19a = 0;
|
||||
|
||||
mpMeterDraw = new dMeter2Draw_c(mpHeap);
|
||||
mpMeterDraw = JKR_NEW dMeter2Draw_c(mpHeap);
|
||||
|
||||
field_0x130 = mpMeterDraw->getNowLightDropRateCalc();
|
||||
mpHeap->getTotalFreeSize();
|
||||
@@ -221,7 +221,7 @@ int dMeter2_c::_create() {
|
||||
|
||||
mpMap = NULL;
|
||||
if (dMeterMap_c::isEnableDispMapAndMapDispSizeTypeNo()) {
|
||||
mpMap = new dMeterMap_c(mpMeterDraw->getMainScreenPtr());
|
||||
mpMap = JKR_NEW dMeterMap_c(mpMeterDraw->getMainScreenPtr());
|
||||
} else {
|
||||
if (g_meter2_info.mMapStatus == 2) {
|
||||
g_meter2_info.mMapStatus = 0;
|
||||
@@ -360,30 +360,30 @@ int dMeter2_c::_delete() {
|
||||
|
||||
mpHeap->getTotalFreeSize();
|
||||
if (mpMap != NULL) {
|
||||
delete mpMap;
|
||||
JKR_DELETE(mpMap);
|
||||
mpMap = NULL;
|
||||
}
|
||||
|
||||
mpHeap->getTotalFreeSize();
|
||||
mDoExt_setCurrentHeap(mpSubHeap);
|
||||
if (mpSubContents != NULL) {
|
||||
delete mpSubContents;
|
||||
JKR_DELETE(mpSubContents);
|
||||
mpSubContents = NULL;
|
||||
}
|
||||
|
||||
if (mpSubSubContents != NULL) {
|
||||
delete mpSubSubContents;
|
||||
JKR_DELETE(mpSubSubContents);
|
||||
mpSubSubContents = NULL;
|
||||
}
|
||||
|
||||
mpHeap->getTotalFreeSize();
|
||||
if (field_0x11c != NULL) {
|
||||
delete field_0x11c;
|
||||
JKR_DELETE(field_0x11c);
|
||||
field_0x11c = NULL;
|
||||
}
|
||||
|
||||
mDoExt_setCurrentHeap(heap);
|
||||
delete mpMeterDraw;
|
||||
JKR_DELETE(mpMeterDraw);
|
||||
mpMeterDraw = NULL;
|
||||
|
||||
fopMsgM_destroyExpHeap(mpSubHeap);
|
||||
@@ -398,7 +398,7 @@ int dMeter2_c::emphasisButtonDelete() {
|
||||
mpEmpButton->hideAll();
|
||||
|
||||
if (heap != NULL) {
|
||||
delete mpEmpButton;
|
||||
JKR_DELETE(mpEmpButton);
|
||||
mpEmpButton = NULL;
|
||||
heap->freeAll();
|
||||
dComIfGp_offHeapLockFlag(8);
|
||||
@@ -2334,7 +2334,7 @@ void dMeter2_c::checkSubContents() {
|
||||
killSubContents(4);
|
||||
|
||||
if (mSubContentType == 0) {
|
||||
mpSubContents = new dScope_c(0);
|
||||
mpSubContents = JKR_NEW dScope_c(0);
|
||||
mSubContentType = 4;
|
||||
}
|
||||
return;
|
||||
@@ -2346,7 +2346,7 @@ void dMeter2_c::checkSubContents() {
|
||||
|
||||
if (mSubContentType == 0) {
|
||||
mpSubHeap->getTotalFreeSize();
|
||||
mpSubContents = new dMeterHakusha_c(mpMeterDraw->getMainScreenPtr());
|
||||
mpSubContents = JKR_NEW dMeterHakusha_c(mpMeterDraw->getMainScreenPtr());
|
||||
mSubContentType = 1;
|
||||
}
|
||||
return;
|
||||
@@ -2357,8 +2357,8 @@ void dMeter2_c::checkSubContents() {
|
||||
killSubContents(5);
|
||||
|
||||
if (mSubContentType == 0) {
|
||||
mpSubContents = new dMeterHaihai_c(0);
|
||||
mpSubSubContents = new dMeterString_c(dMeter2Info_getMeterStringType());
|
||||
mpSubContents = JKR_NEW dMeterHaihai_c(0);
|
||||
mpSubSubContents = JKR_NEW dMeterString_c(dMeter2Info_getMeterStringType());
|
||||
mSubContentType = 5;
|
||||
mSubContentsStringType = dMeter2Info_getMeterStringType();
|
||||
}
|
||||
@@ -2366,14 +2366,14 @@ void dMeter2_c::checkSubContents() {
|
||||
killSubContents(2);
|
||||
|
||||
if (mSubContentType == 0) {
|
||||
mpSubContents = new dMeterHaihai_c(0);
|
||||
mpSubContents = JKR_NEW dMeterHaihai_c(0);
|
||||
mSubContentType = 2;
|
||||
}
|
||||
} else if (dMeter2Info_getMeterStringType() != 0) {
|
||||
killSubContents(3);
|
||||
|
||||
if (mSubContentType == 0) {
|
||||
mpSubContents = new dMeterString_c(dMeter2Info_getMeterStringType());
|
||||
mpSubContents = JKR_NEW dMeterString_c(dMeter2Info_getMeterStringType());
|
||||
mSubContentType = 3;
|
||||
}
|
||||
} else if (mSubContentType == 4) {
|
||||
@@ -2381,13 +2381,13 @@ void dMeter2_c::checkSubContents() {
|
||||
bool free_heap = false;
|
||||
|
||||
if (mpSubContents != NULL && mpSubContents->isDead()) {
|
||||
delete mpSubContents;
|
||||
JKR_DELETE(mpSubContents);
|
||||
mpSubContents = NULL;
|
||||
free_heap = true;
|
||||
}
|
||||
|
||||
if (mpSubSubContents != NULL && mpSubSubContents->isDead()) {
|
||||
delete mpSubSubContents;
|
||||
JKR_DELETE(mpSubSubContents);
|
||||
mpSubSubContents = NULL;
|
||||
free_heap = true;
|
||||
}
|
||||
@@ -2404,13 +2404,13 @@ void dMeter2_c::checkSubContents() {
|
||||
bool free_heap = false;
|
||||
|
||||
if (mpSubContents != NULL) {
|
||||
delete mpSubContents;
|
||||
JKR_DELETE(mpSubContents);
|
||||
mpSubContents = NULL;
|
||||
free_heap = true;
|
||||
}
|
||||
|
||||
if (mpSubSubContents != NULL) {
|
||||
delete mpSubSubContents;
|
||||
JKR_DELETE(mpSubSubContents);
|
||||
mpSubSubContents = NULL;
|
||||
free_heap = true;
|
||||
}
|
||||
@@ -2440,7 +2440,7 @@ void dMeter2_c::check2DContents() {
|
||||
field_0x108 = mDoExt_setCurrentHeap(dComIfGp_getSubHeap2D(8));
|
||||
}
|
||||
|
||||
mpEmpButton = new dMeterButton_c();
|
||||
mpEmpButton = JKR_NEW dMeterButton_c();
|
||||
}
|
||||
} else if (dComIfGp_isHeapLockFlag() == 5 && !dMeter2Info_isFloatingMessageVisible()) {
|
||||
if (!mpMeterDraw->isEmphasisA() && !mpMeterDraw->isEmphasisB() &&
|
||||
@@ -2449,7 +2449,7 @@ void dMeter2_c::check2DContents() {
|
||||
!mpMeterDraw->isEmphasisS() && !mpMeterDraw->isEmphasisX() &&
|
||||
!mpMeterDraw->isEmphasisY() && !mpMeterDraw->isEmphasisBin() && mpEmpButton->isClose())
|
||||
{
|
||||
delete mpEmpButton;
|
||||
JKR_DELETE(mpEmpButton);
|
||||
mpEmpButton = NULL;
|
||||
dComIfGp_getSubHeap2D(8)->freeAll();
|
||||
|
||||
@@ -2987,13 +2987,13 @@ void dMeter2_c::killSubContents(u8 param_0) {
|
||||
bool free = false;
|
||||
|
||||
if (mpSubContents != NULL) {
|
||||
delete mpSubContents;
|
||||
JKR_DELETE(mpSubContents);
|
||||
mpSubContents = NULL;
|
||||
free = true;
|
||||
}
|
||||
|
||||
if (mpSubSubContents != NULL) {
|
||||
delete mpSubSubContents;
|
||||
JKR_DELETE(mpSubSubContents);
|
||||
mpSubSubContents = NULL;
|
||||
free = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user