fixed a memory leak bug in StdAwk.cpp when compiled for mchar

This commit is contained in:
hyung-hwan 2014-03-11 14:54:05 +00:00
parent fa3757222a
commit 35839c9f67
2 changed files with 8 additions and 4 deletions

View File

@ -170,13 +170,11 @@ oops:
void StdAwk::close ()
{
#if defined(QSE_CHAR_IS_WCHAR)
if (this->cmgrtab_inited)
{
qse_htb_fini (&this->cmgrtab);
this->cmgrtab_inited = false;
}
#endif
clearConsoleOutputs ();
Awk::close ();

View File

@ -68,10 +68,16 @@ static QSE_INLINE_ALWAYS qse_size_t szlog2 (qse_size_t n)
#define BITS (QSE_SIZEOF_SIZE_T * 8)
int x = BITS - 1;
#if QSE_SIZEOF_SIZE_T >= 32
#if QSE_SIZEOF_SIZE_T >= 128
# error qse_size_t too large. unsupported platform
#endif
#if QSE_SIZEOF_SIZE_T >= 64
if ((n & (~(qse_size_t)0 << (BITS-128))) == 0) { x -= 256; n <<= 256; }
#endif
#if QSE_SIZEOF_SIZE_T >= 32
if ((n & (~(qse_size_t)0 << (BITS-128))) == 0) { x -= 128; n <<= 128; }
#endif
#if QSE_SIZEOF_SIZE_T >= 16
if ((n & (~(qse_size_t)0 << (BITS-64))) == 0) { x -= 64; n <<= 64; }
#endif
@ -151,7 +157,7 @@ int qse_xma_init (qse_xma_t* xma, qse_mmgr_t* mmgr, qse_size_t zonesize)
QSE_MEMSET (xma, 0, QSE_SIZEOF(*xma));
xma->mmgr = mmgr;
xma->bdec = szlog2(FIXED*ALIGN); /* precalculate the decrement value */
xma->bdec = szlog2(FIXED * ALIGN); /* precalculate the decrement value */
/* at this point, the 'free' chunk is a only block available */