From: Peter Johnson Date: Sat, 1 Dec 2001 19:19:56 +0000 (-0000) Subject: (Mostly) Clean up floatnum internal allocations. X-Git-Tag: v0.1.0~160 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bcb83da56ec8bf52247198f9134bce4d909e7ec;p=yasm (Mostly) Clean up floatnum internal allocations. svn path=/trunk/yasm/; revision=370 --- diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 18a8f550..ef560eae 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -37,6 +37,7 @@ #include "globals.h" #include "options.h" #include "errwarn.h" +#include "floatnum.h" #include "symrec.h" #include "bytecode.h" @@ -205,6 +206,8 @@ main(int argc, char *argv[]) symrec_delete_all(); filename_delete_all(); + floatnum_shutdown(); + BitVector_Shutdown(); return EXIT_SUCCESS; } diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c index 0f8e870b..d9006349 100644 --- a/libyasm/floatnum.c +++ b/libyasm/floatnum.c @@ -183,6 +183,29 @@ POT_Table_Init(void) } /*@=compdef@*/ +/*@-globstate@*/ +void +floatnum_shutdown(void) +{ + int i; + + if (!POT_TableN) + return; + + /* Un-offset POT_TableP */ + POT_TableP--; + + for (i=0; i<14; i++) { + BitVector_Destroy(POT_TableN[i].f.mantissa); + BitVector_Destroy(POT_TableP[i].f.mantissa); + } + BitVector_Destroy(POT_TableP[14].f.mantissa); + + xfree(POT_TableN); + xfree(POT_TableP); +} +/*@=globstate@*/ + static void floatnum_normalize(floatnum *flt) { diff --git a/libyasm/floatnum.h b/libyasm/floatnum.h index b5ab637c..c699e317 100644 --- a/libyasm/floatnum.h +++ b/libyasm/floatnum.h @@ -24,6 +24,9 @@ #ifndef YASM_FLOATNUM_H #define YASM_FLOATNUM_H +/* Clean up internal allocations */ +void floatnum_shutdown(void); + /*@only@*/ floatnum *floatnum_new(const char *str); /*@only@*/ floatnum *floatnum_copy(const floatnum *flt); void floatnum_delete(/*@only@*/ floatnum *flt); diff --git a/src/floatnum.c b/src/floatnum.c index 0f8e870b..d9006349 100644 --- a/src/floatnum.c +++ b/src/floatnum.c @@ -183,6 +183,29 @@ POT_Table_Init(void) } /*@=compdef@*/ +/*@-globstate@*/ +void +floatnum_shutdown(void) +{ + int i; + + if (!POT_TableN) + return; + + /* Un-offset POT_TableP */ + POT_TableP--; + + for (i=0; i<14; i++) { + BitVector_Destroy(POT_TableN[i].f.mantissa); + BitVector_Destroy(POT_TableP[i].f.mantissa); + } + BitVector_Destroy(POT_TableP[14].f.mantissa); + + xfree(POT_TableN); + xfree(POT_TableP); +} +/*@=globstate@*/ + static void floatnum_normalize(floatnum *flt) { diff --git a/src/floatnum.h b/src/floatnum.h index b5ab637c..c699e317 100644 --- a/src/floatnum.h +++ b/src/floatnum.h @@ -24,6 +24,9 @@ #ifndef YASM_FLOATNUM_H #define YASM_FLOATNUM_H +/* Clean up internal allocations */ +void floatnum_shutdown(void); + /*@only@*/ floatnum *floatnum_new(const char *str); /*@only@*/ floatnum *floatnum_copy(const floatnum *flt); void floatnum_delete(/*@only@*/ floatnum *flt); diff --git a/src/main.c b/src/main.c index 18a8f550..ef560eae 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ #include "globals.h" #include "options.h" #include "errwarn.h" +#include "floatnum.h" #include "symrec.h" #include "bytecode.h" @@ -205,6 +206,8 @@ main(int argc, char *argv[]) symrec_delete_all(); filename_delete_all(); + floatnum_shutdown(); + BitVector_Shutdown(); return EXIT_SUCCESS; }