redefined some memory allocation functions

added the ismap builtin function to awk
This commit is contained in:
2019-05-02 11:29:51 +00:00
parent f9e5c3920d
commit 006042f6cb
8 changed files with 139 additions and 131 deletions

View File

@ -31,6 +31,7 @@
#include <qse/macros.h>
#include <qse/cmn/htb.h>
#include <qse/cmn/str.h>
#include <qse/cmn/mem.h>
/** \file
* An embeddable AWK interpreter is defined in this header file.
@ -129,6 +130,17 @@ struct qse_awk_alt_t
*/
typedef struct qse_awk_rtx_t qse_awk_rtx_t;
#define QSE_AWK_RTX_HDR \
int id; \
qse_awk_t* awk
typedef struct qse_awk_rtx_alt_t qse_awk_rtx_alt_t;
struct qse_awk_rtx_alt_t
{
/* ensure that qse_awk_rtx_alt_t matches the beginning part of qse_awk_rtx_t */
QSE_AWK_RTX_HDR;
};
/**
* The qse_awk_loc_t type defines a structure to hold location.
*/
@ -1872,10 +1884,15 @@ QSE_EXPORT void* qse_awk_callocmem (
/**
* The qse_awk_freemem() function frees dynamic memory allocated.
*/
QSE_EXPORT void qse_awk_freemem (
qse_awk_t* awk, /**< awk */
void* ptr /**< memory block to free */
);
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE void qse_awk_freemem (qse_awk_t* awk, void* ptr)
{
QSE_MMGR_FREE (((qse_awk_alt_t*)(awk))->mmgr, ptr);
}
#else
# define qse_awk_freemem(awk, ptr) QSE_MMGR_FREE(((qse_awk_alt_t*)(awk))->mmgr, ptr);
#endif
/**
* The qse_awk_strdup() function is used to duplicate a string using
@ -2986,10 +3003,14 @@ QSE_EXPORT void* qse_awk_rtx_callocmem (
* The qse_awk_rtx_freemem() function frees a memory block pointed to by \a ptr
* using the memory manager of a runtime ocntext \a rtx.
*/
QSE_EXPORT void qse_awk_rtx_freemem (
qse_awk_rtx_t* rtx, /**< runtime context */
void* ptr /**< memory block pointer */
);
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE void qse_awk_rtx_freemem (qse_awk_rtx_t* rtx, void* ptr)
{
qse_awk_freemem (((qse_awk_rtx_alt_t*)rtx)->awk, ptr);
}
#else
# define qse_awk_rtx_freemem(rtx,ptr) qse_awk_freemem(((qse_awk_rtx_alt_t*)rtx)->awk, ptr)
#endif
/**
* The qse_getawknilval() function returns the pointer to the predefined

View File

@ -123,7 +123,7 @@
# define qse_map_id_t qse_rbt_id_t
# define qse_map_t qse_rbt_t
# define qse_map_pair_t qse_rbt_pair_t
# define qse_map_style_t qse_rbt_style_t
# define qse_map_style_t qse_rbt_style_t
# define qse_map_cbserter_t qse_rbt_cbserter_t
# define qse_map_walker_t qse_rbt_walker_t
# define QSE_MAP_COPIER_SIMPLE QSE_RBT_COPIER_SIMPLE
@ -132,8 +132,8 @@
# define QSE_MAP_FREEER_DEFAULT QSE_RBT_FREEER_DEFAULT
# define QSE_MAP_COMPER_DEFAULT QSE_RBT_COMPER_DEFAULT
# define QSE_MAP_KEEPER_DEFAULT QSE_RBT_KEEPER_DEFAULT
/*# define QSE_MAP_SIZER_DEFAULT
# define QSE_MAP_HASHER_DEFAULT*/
# define QSE_MAP_SIZER_DEFAULT (QSE_NULL)
# define QSE_MAP_HASHER_DEFAULT (QSE_NULL)
# define QSE_MAP_SIZE(map) QSE_RBT_SIZE(map)
# define QSE_MAP_KCOPIER(map) QSE_RBT_KCOPIER(map)
# define QSE_MAP_VCOPIER(map) QSE_RBT_VCOPIER(map)