*** empty log message ***

This commit is contained in:
hyung-hwan 2006-09-01 04:03:28 +00:00
parent 758bebd0d3
commit a4833392b7
5 changed files with 57 additions and 39 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.75 2006-09-01 03:44:15 bacon Exp $ * $Id: awk.c,v 1.76 2006-09-01 04:03:28 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -19,8 +19,12 @@ xp_awk_t* xp_awk_open (xp_awk_syscas_t* syscas)
syscas->malloc == XP_NULL || syscas->malloc == XP_NULL ||
syscas->free == XP_NULL) return XP_NULL; syscas->free == XP_NULL) return XP_NULL;
#if defined(_WIN32) && defined(_DEBUG)
awk = (xp_awk_t*) malloc (xp_sizeof(xp_awk_t));
#else
awk = (xp_awk_t*) syscas->malloc ( awk = (xp_awk_t*) syscas->malloc (
xp_sizeof(xp_awk_t), syscas->custom_data); xp_sizeof(xp_awk_t), syscas->custom_data);
#endif
if (awk == XP_NULL) return XP_NULL; if (awk == XP_NULL) return XP_NULL;
awk->syscas = syscas; awk->syscas = syscas;
@ -114,7 +118,7 @@ int xp_awk_close (xp_awk_t* awk)
xp_awk_tab_close (&awk->parse.params); xp_awk_tab_close (&awk->parse.params);
xp_awk_str_close (&awk->token.name); xp_awk_str_close (&awk->token.name);
/* XP_AWK_MALLOC, XP_AWK_FREE, etc can not be used /* XP_AWK_ALLOC, XP_AWK_FREE, etc can not be used
* from the next line onwards */ * from the next line onwards */
XP_AWK_FREE (awk, awk); XP_AWK_FREE (awk, awk);
return 0; return 0;

View File

@ -235,6 +235,10 @@ SOURCE=.\sa.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\str.c
# End Source File
# Begin Source File
SOURCE=.\tab.c SOURCE=.\tab.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -283,6 +287,10 @@ SOURCE=.\sa.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\str.h
# End Source File
# Begin Source File
SOURCE=.\tab.h SOURCE=.\tab.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk_i.h,v 1.51 2006-08-31 16:00:18 bacon Exp $ * $Id: awk_i.h,v 1.52 2006-09-01 04:03:28 bacon Exp $
*/ */
#ifndef _XP_AWK_AWKI_H_ #ifndef _XP_AWK_AWKI_H_
@ -39,12 +39,30 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
#define XP_AWK_MAX_LOCALS 9999 #define XP_AWK_MAX_LOCALS 9999
#define XP_AWK_MAX_PARAMS 9999 #define XP_AWK_MAX_PARAMS 9999
#define XP_AWK_MALLOC(awk,size) \ #if defined(_WIN32) && defined(_DEBUG)
(awk)->syscas->malloc (size, (awk)->syscas->custom_data) #define XP_AWK_MALLOC(awk,size) malloc (size)
#define XP_AWK_REALLOC(awk,ptr,size) \ #define XP_AWK_REALLOC(awk,ptr,size) realloc (ptr, size)
(awk)->syscas->realloc (ptr, size, (awk)->syscas->custom_data) #define XP_AWK_FREE(awk,ptr) free (ptr)
#define XP_AWK_FREE(awk,ptr) \ #else
(awk)->syscas->free (ptr, (awk)->syscas->custom_data) #define XP_AWK_MALLOC(awk,size) \
(awk)->syscas->malloc (size, (awk)->syscas->custom_data)
#define XP_AWK_REALLOC(awk,ptr,size) \
(awk)->syscas->realloc (ptr, size, (awk)->syscas->custom_data)
#define XP_AWK_FREE(awk,ptr) \
(awk)->syscas->free (ptr, (awk)->syscas->custom_data)
#endif
#define XP_AWK_LOCK(awk) \
do { \
if (awk->syscas != XP_NULL && awk->syscas->lock != XP_NULL) \
awk->syscas->lock (awk, awk->syscas->custom_data); \
} while (0)
#define XP_AWK_UNLOCK(awk) \
do { \
if (awk->syscas != XP_NULL && awk->syscas->unlock != XP_NULL) \
awk->syscas->unlock (awk, awk->syscas->custom_data); \
} while (0)
struct xp_awk_tree_t struct xp_awk_tree_t
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.191 2006-09-01 03:44:16 bacon Exp $ * $Id: run.c,v 1.192 2006-09-01 04:03:28 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -329,7 +329,7 @@ int xp_awk_run (xp_awk_t* awk, xp_awk_runios_t* runios, xp_awk_runcbs_t* runcbs)
{ {
awk->errnum = errnum; awk->errnum = errnum;
__del_run (awk, run); __del_run (awk, run);
awk->syscas->free (run, awk->syscas->custom_data); XP_AWK_FREE (awk, run);
return -1; return -1;
} }
@ -360,7 +360,7 @@ int xp_awk_run (xp_awk_t* awk, xp_awk_runios_t* runios, xp_awk_runcbs_t* runcbs)
__deinit_run (run); __deinit_run (run);
__del_run (awk, run); __del_run (awk, run);
awk->syscas->free (run, awk->syscas->custom_data); XP_AWK_FREE (awk, run);
return n; return n;
} }
@ -370,8 +370,7 @@ int xp_awk_stop (xp_awk_t* awk, void* run)
xp_awk_run_t* r; xp_awk_run_t* r;
int n = 0; int n = 0;
if (awk->syscas != XP_NULL && awk->syscas->lock != XP_NULL) XP_AWK_LOCK (awk);
awk->syscas->lock (awk, awk->syscas->custom_data);
/* check if the run handle given is valid */ /* check if the run handle given is valid */
for (r = awk->run.ptr; r != XP_NULL; r = r->next) for (r = awk->run.ptr; r != XP_NULL; r = r->next)
@ -392,8 +391,7 @@ int xp_awk_stop (xp_awk_t* awk, void* run)
n = -1; n = -1;
} }
if (awk->syscas != XP_NULL && awk->syscas->unlock != XP_NULL) XP_AWK_UNLOCK (awk);
awk->syscas->unlock (awk, awk->syscas->custom_data);
return n; return n;
} }
@ -402,16 +400,14 @@ void xp_awk_stopall (xp_awk_t* awk)
{ {
xp_awk_run_t* r; xp_awk_run_t* r;
if (awk->syscas != XP_NULL && awk->syscas->lock != XP_NULL) XP_AWK_LOCK (awk);
awk->syscas->lock (awk, awk->syscas->custom_data);
for (r = awk->run.ptr; r != XP_NULL; r = r->next) for (r = awk->run.ptr; r != XP_NULL; r = r->next)
{ {
r->exit_level = EXIT_ABORT; r->exit_level = EXIT_ABORT;
} }
if (awk->syscas != XP_NULL && awk->syscas->unlock != XP_NULL) XP_AWK_UNLOCK (awk);
awk->syscas->unlock (awk, awk->syscas->custom_data);
} }
int xp_awk_getrunerrnum (xp_awk_t* awk, void* run, int* errnum) int xp_awk_getrunerrnum (xp_awk_t* awk, void* run, int* errnum)
@ -419,8 +415,7 @@ int xp_awk_getrunerrnum (xp_awk_t* awk, void* run, int* errnum)
xp_awk_run_t* r; xp_awk_run_t* r;
int n = 0; int n = 0;
if (awk->syscas != XP_NULL && awk->syscas->lock != XP_NULL) XP_AWK_LOCK (awk);
awk->syscas->lock (awk, awk->syscas->custom_data);
for (r = awk->run.ptr; r != XP_NULL; r = r->next) for (r = awk->run.ptr; r != XP_NULL; r = r->next)
{ {
@ -438,8 +433,7 @@ int xp_awk_getrunerrnum (xp_awk_t* awk, void* run, int* errnum)
n = -1; n = -1;
} }
if (awk->syscas != XP_NULL && awk->syscas->unlock != XP_NULL) XP_AWK_UNLOCK (awk);
awk->syscas->unlock (awk, awk->syscas->custom_data);
return n; return n;
} }
@ -451,8 +445,7 @@ static void __free_namedval (void* run, void* val)
static void __add_run (xp_awk_t* awk, xp_awk_run_t* run) static void __add_run (xp_awk_t* awk, xp_awk_run_t* run)
{ {
if (awk->syscas != XP_NULL && awk->syscas->lock != XP_NULL) XP_AWK_LOCK (awk);
awk->syscas->lock (awk, awk->syscas->custom_data);
run->awk = awk; run->awk = awk;
run->prev = XP_NULL; run->prev = XP_NULL;
@ -461,14 +454,12 @@ static void __add_run (xp_awk_t* awk, xp_awk_run_t* run)
awk->run.ptr = run; awk->run.ptr = run;
awk->run.count++; awk->run.count++;
if (awk->syscas != XP_NULL && awk->syscas->unlock != XP_NULL) XP_AWK_UNLOCK (awk);
awk->syscas->unlock (awk, awk->syscas->custom_data);
} }
static void __del_run (xp_awk_t* awk, xp_awk_run_t* run) static void __del_run (xp_awk_t* awk, xp_awk_run_t* run)
{ {
if (awk->syscas != XP_NULL && awk->syscas->lock != XP_NULL) XP_AWK_LOCK (awk);
awk->syscas->lock (awk, awk->syscas->custom_data);
xp_assert (awk->run.ptr != XP_NULL); xp_assert (awk->run.ptr != XP_NULL);
@ -486,8 +477,7 @@ static void __del_run (xp_awk_t* awk, xp_awk_run_t* run)
run->awk = XP_NULL; run->awk = XP_NULL;
awk->run.count--; awk->run.count--;
if (awk->syscas != XP_NULL && awk->syscas->unlock != XP_NULL) XP_AWK_UNLOCK (awk);
awk->syscas->unlock (awk, awk->syscas->custom_data);
} }
static int __init_run ( static int __init_run (
@ -4887,9 +4877,7 @@ static int __recomp_record_fields (
{ {
xp_memcpy (tmp, run->inrec.flds, xp_memcpy (tmp, run->inrec.flds,
xp_sizeof(*run->inrec.flds) * run->inrec.maxflds); xp_sizeof(*run->inrec.flds) * run->inrec.maxflds);
run->awk->syscas->free ( XP_AWK_FREE (run->awk, run->inrec.flds);
run->inrec.flds,
run->awk->syscas->custom_data);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.82 2006-09-01 03:44:51 bacon Exp $ * $Id: awk.c,v 1.83 2006-09-01 04:03:13 bacon Exp $
*/ */
#include <xp/awk/awk.h> #include <xp/awk/awk.h>
@ -47,7 +47,7 @@
#define xp_free free #define xp_free free
#endif #endif
#if defined(_WIN32) && defined(__STAND_ALONE) && defined(_DEBUG) #if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC #define _CRTDBG_MAP_ALLOC
#include <crtdbg.h> #include <crtdbg.h>
#endif #endif
@ -741,7 +741,7 @@ int xp_main (int argc, xp_char_t* argv[])
#if defined(__linux) && defined(_DEBUG) #if defined(__linux) && defined(_DEBUG)
mtrace (); mtrace ();
#endif #endif
/*#if defined(_WIN32) && defined(__STAND_ALONE) && defined(_DEBUG) /*#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag (_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF); _CrtSetDbgFlag (_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);
#endif*/ #endif*/
@ -750,7 +750,7 @@ int xp_main (int argc, xp_char_t* argv[])
#if defined(__linux) && defined(_DEBUG) #if defined(__linux) && defined(_DEBUG)
muntrace (); muntrace ();
#endif #endif
#if defined(_WIN32) && defined(__STAND_ALONE) && defined(_DEBUG) #if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
_CrtDumpMemoryLeaks (); _CrtDumpMemoryLeaks ();
wprintf (L"Press ENTER to quit\n"); wprintf (L"Press ENTER to quit\n");
getchar (); getchar ();