fixed a memory leak bug in the uci module
This commit is contained in:
parent
31edff2391
commit
b53fe11c04
@ -12,11 +12,11 @@ libawksys_la_SOURCES = sys.c
|
|||||||
libawksys_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
libawksys_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||||
libawksys_la_LIBADD = -lqseawk -lqsecmn
|
libawksys_la_LIBADD = -lqseawk -lqsecmn
|
||||||
|
|
||||||
#if HAVE_LIBUCI
|
if HAVE_LIBUCI
|
||||||
|
|
||||||
mod_LTLIBRARIES += libawkuci.la
|
mod_LTLIBRARIES += libawkuci.la
|
||||||
libawkuci_la_SOURCES = uci.c
|
libawkuci_la_SOURCES = uci.c
|
||||||
libawkuci_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
libawkuci_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||||
libawkuci_la_LIBADD = -lqseawk -lqsecmn $(UCI_LIBS)
|
libawkuci_la_LIBADD = -lqseawk -lqsecmn $(UCI_LIBS)
|
||||||
|
|
||||||
#endif
|
endif
|
||||||
|
@ -34,6 +34,7 @@ PRE_UNINSTALL = :
|
|||||||
POST_UNINSTALL = :
|
POST_UNINSTALL = :
|
||||||
build_triplet = @build@
|
build_triplet = @build@
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
|
@HAVE_LIBUCI_TRUE@am__append_1 = libawkuci.la
|
||||||
subdir = mod/awk
|
subdir = mod/awk
|
||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
@ -85,12 +86,14 @@ libawksys_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|||||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||||
$(libawksys_la_LDFLAGS) $(LDFLAGS) -o $@
|
$(libawksys_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
am__DEPENDENCIES_1 =
|
am__DEPENDENCIES_1 =
|
||||||
libawkuci_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
@HAVE_LIBUCI_TRUE@libawkuci_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||||
am_libawkuci_la_OBJECTS = uci.lo
|
am__libawkuci_la_SOURCES_DIST = uci.c
|
||||||
|
@HAVE_LIBUCI_TRUE@am_libawkuci_la_OBJECTS = uci.lo
|
||||||
libawkuci_la_OBJECTS = $(am_libawkuci_la_OBJECTS)
|
libawkuci_la_OBJECTS = $(am_libawkuci_la_OBJECTS)
|
||||||
libawkuci_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
libawkuci_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||||
$(libawkuci_la_LDFLAGS) $(LDFLAGS) -o $@
|
$(libawkuci_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
|
@HAVE_LIBUCI_TRUE@am_libawkuci_la_rpath = -rpath $(moddir)
|
||||||
DEFAULT_INCLUDES =
|
DEFAULT_INCLUDES =
|
||||||
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
||||||
am__depfiles_maybe = depfiles
|
am__depfiles_maybe = depfiles
|
||||||
@ -105,7 +108,8 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
|||||||
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||||
$(LDFLAGS) -o $@
|
$(LDFLAGS) -o $@
|
||||||
SOURCES = $(libawksys_la_SOURCES) $(libawkuci_la_SOURCES)
|
SOURCES = $(libawksys_la_SOURCES) $(libawkuci_la_SOURCES)
|
||||||
DIST_SOURCES = $(libawksys_la_SOURCES) $(libawkuci_la_SOURCES)
|
DIST_SOURCES = $(libawksys_la_SOURCES) \
|
||||||
|
$(am__libawkuci_la_SOURCES_DIST)
|
||||||
ETAGS = etags
|
ETAGS = etags
|
||||||
CTAGS = ctags
|
CTAGS = ctags
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
@ -287,15 +291,13 @@ AM_CPPFLAGS = \
|
|||||||
-I$(includedir)
|
-I$(includedir)
|
||||||
|
|
||||||
moddir = $(libdir)/qse
|
moddir = $(libdir)/qse
|
||||||
|
mod_LTLIBRARIES = libawksys.la $(am__append_1)
|
||||||
#if HAVE_LIBUCI
|
|
||||||
mod_LTLIBRARIES = libawksys.la libawkuci.la
|
|
||||||
libawksys_la_SOURCES = sys.c
|
libawksys_la_SOURCES = sys.c
|
||||||
libawksys_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
libawksys_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||||
libawksys_la_LIBADD = -lqseawk -lqsecmn
|
libawksys_la_LIBADD = -lqseawk -lqsecmn
|
||||||
libawkuci_la_SOURCES = uci.c
|
@HAVE_LIBUCI_TRUE@libawkuci_la_SOURCES = uci.c
|
||||||
libawkuci_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
@HAVE_LIBUCI_TRUE@libawkuci_la_LDFLAGS = -L$(abs_builddir)/../../lib/cmn -L$(abs_builddir)/../../lib/awk -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||||
libawkuci_la_LIBADD = -lqseawk -lqsecmn $(UCI_LIBS)
|
@HAVE_LIBUCI_TRUE@libawkuci_la_LIBADD = -lqseawk -lqsecmn $(UCI_LIBS)
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@ -364,7 +366,7 @@ clean-modLTLIBRARIES:
|
|||||||
libawksys.la: $(libawksys_la_OBJECTS) $(libawksys_la_DEPENDENCIES) $(EXTRA_libawksys_la_DEPENDENCIES)
|
libawksys.la: $(libawksys_la_OBJECTS) $(libawksys_la_DEPENDENCIES) $(EXTRA_libawksys_la_DEPENDENCIES)
|
||||||
$(libawksys_la_LINK) -rpath $(moddir) $(libawksys_la_OBJECTS) $(libawksys_la_LIBADD) $(LIBS)
|
$(libawksys_la_LINK) -rpath $(moddir) $(libawksys_la_OBJECTS) $(libawksys_la_LIBADD) $(LIBS)
|
||||||
libawkuci.la: $(libawkuci_la_OBJECTS) $(libawkuci_la_DEPENDENCIES) $(EXTRA_libawkuci_la_DEPENDENCIES)
|
libawkuci.la: $(libawkuci_la_OBJECTS) $(libawkuci_la_DEPENDENCIES) $(EXTRA_libawkuci_la_DEPENDENCIES)
|
||||||
$(libawkuci_la_LINK) -rpath $(moddir) $(libawkuci_la_OBJECTS) $(libawkuci_la_LIBADD) $(LIBS)
|
$(libawkuci_la_LINK) $(am_libawkuci_la_rpath) $(libawkuci_la_OBJECTS) $(libawkuci_la_LIBADD) $(LIBS)
|
||||||
|
|
||||||
mostlyclean-compile:
|
mostlyclean-compile:
|
||||||
-rm -f *.$(OBJEXT)
|
-rm -f *.$(OBJEXT)
|
||||||
@ -609,8 +611,6 @@ uninstall-am: uninstall-modLTLIBRARIES
|
|||||||
uninstall-am uninstall-modLTLIBRARIES
|
uninstall-am uninstall-modLTLIBRARIES
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
.NOEXPORT:
|
.NOEXPORT:
|
||||||
|
@ -6,26 +6,7 @@
|
|||||||
#if defined(HAVE_UCI_H)
|
#if defined(HAVE_UCI_H)
|
||||||
# include <uci.h>
|
# include <uci.h>
|
||||||
#else
|
#else
|
||||||
/*# error this module needs uci.h*/
|
# error this module needs uci.h
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
struct uci_context
|
|
||||||
{
|
|
||||||
int a;
|
|
||||||
int b;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct uci_context* uci_alloc_context(void)
|
|
||||||
{
|
|
||||||
qse_printf (QSE_T("uci_alloc_context....\n"));
|
|
||||||
return malloc (sizeof(struct uci_context));
|
|
||||||
}
|
|
||||||
|
|
||||||
void uci_free_context (struct uci_context* c)
|
|
||||||
{
|
|
||||||
qse_printf (QSE_T("uci_free_context....\n"));
|
|
||||||
free (c);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct uctx_list_t uctx_list_t;
|
typedef struct uctx_list_t uctx_list_t;
|
||||||
@ -45,6 +26,7 @@ struct uctx_list_t
|
|||||||
uctx_node_t* tail;
|
uctx_node_t* tail;
|
||||||
uctx_node_t* free;
|
uctx_node_t* free;
|
||||||
|
|
||||||
|
/* mapping table to map 'id' to 'node' */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uctx_node_t** tab;
|
uctx_node_t** tab;
|
||||||
@ -124,17 +106,18 @@ static void free_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list, uctx_node_t*
|
|||||||
|
|
||||||
list->map.tab[node->id] = QSE_NULL;
|
list->map.tab[node->id] = QSE_NULL;
|
||||||
|
|
||||||
|
uci_free_context (node->ctx);
|
||||||
|
|
||||||
if (list->map.high == node->id + 1)
|
if (list->map.high == node->id + 1)
|
||||||
{
|
{
|
||||||
/* destroy the actual node if the node to be freed has the
|
/* destroy the actual node if the node to be freed has the
|
||||||
* highest id */
|
* highest id */
|
||||||
uci_free_context (node->ctx);
|
|
||||||
QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), node);
|
QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), node);
|
||||||
list->map.high--;
|
list->map.high--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* otherwise, chain it to the free list */
|
/* otherwise, chain the node to the free list */
|
||||||
node->next = list->free;
|
node->next = list->free;
|
||||||
list->free = node;
|
list->free = node;
|
||||||
}
|
}
|
||||||
@ -156,6 +139,7 @@ static void free_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list, uctx_node_t*
|
|||||||
QSE_MMGR_FREE (mmgr, curnode);
|
QSE_MMGR_FREE (mmgr, curnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qse_printf (QSE_T("freeing map...\n"));
|
||||||
QSE_MMGR_FREE (mmgr, list->map.tab);
|
QSE_MMGR_FREE (mmgr, list->map.tab);
|
||||||
list->map.high = 0;
|
list->map.high = 0;
|
||||||
list->map.capa = 0;
|
list->map.capa = 0;
|
||||||
@ -211,7 +195,7 @@ static int fnc_uci_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
|||||||
list = rtx_to_list (rtx, fi);
|
list = rtx_to_list (rtx, fi);
|
||||||
|
|
||||||
n = qse_awk_rtx_valtolong (
|
n = qse_awk_rtx_valtolong (
|
||||||
rtx, qse_awk_rtx_getarg(rtx, 0), &id);
|
rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||||
if (n <= -1) return -1;
|
if (n <= -1) return -1;
|
||||||
|
|
||||||
retv = qse_awk_rtx_makeintval (
|
retv = qse_awk_rtx_makeintval (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user