From 7e318991fe32bee60f4752449973b2775ac449a9 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Mon, 2 Nov 2020 10:18:13 +0000 Subject: [PATCH] fixed a bug in xma.c --- moo/lib/moo-xma.h | 2 +- moo/lib/xma.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/moo/lib/moo-xma.h b/moo/lib/moo-xma.h index 869dfc0..e31fab7 100644 --- a/moo/lib/moo-xma.h +++ b/moo/lib/moo-xma.h @@ -91,7 +91,7 @@ struct moo_xma_t moo_uint8_t* start; /* zone beginning */ moo_uint8_t* end; /* zone end */ - int external; + int internal; /** pointer array to free memory blocks */ moo_xma_fblk_t* xfree[MOO_XMA_FIXED + MOO_XMA_SIZE_BITS + 1]; diff --git a/moo/lib/xma.c b/moo/lib/xma.c index 682100e..ef3c5ab 100644 --- a/moo/lib/xma.c +++ b/moo/lib/xma.c @@ -173,6 +173,7 @@ int moo_xma_init (moo_xma_t* xma, moo_mmgr_t* mmgr, void* zoneptr, moo_oow_t zon { moo_xma_fblk_t* free; moo_oow_t xfi; + int internal = 0; if (!zoneptr) { @@ -184,10 +185,8 @@ int moo_xma_init (moo_xma_t* xma, moo_mmgr_t* mmgr, void* zoneptr, moo_oow_t zon zoneptr = MOO_MMGR_ALLOC(mmgr, zonesize); if (MOO_UNLIKELY(!zoneptr)) return -1; - } - else - { - xma->external = 1; + + internal = 1; } free = (moo_xma_fblk_t*)zoneptr; @@ -212,6 +211,7 @@ int moo_xma_init (moo_xma_t* xma, moo_mmgr_t* mmgr, void* zoneptr, moo_oow_t zon /* let it be the head, which is natural with only a block */ xma->start = (moo_uint8_t*)free; xma->end = xma->start + zonesize; + xma->internal = 1; /* initialize some statistical variables */ #if defined(MOO_XMA_ENABLE_STAT) @@ -229,7 +229,7 @@ void moo_xma_fini (moo_xma_t* xma) { /* the head must point to the free chunk allocated in init(). * let's deallocate it */ - if (!xma->external) MOO_MMGR_FREE (xma->_mmgr, xma->start); + if (xma->internal) MOO_MMGR_FREE (xma->_mmgr, xma->start); xma->start = MOO_NULL; xma->end = MOO_NULL; }