added a few lines of code to print simple memory allocation counts in cmd/awk/awk.c and cmd/sed/sed.c.

got rid of redundant realloc handler check in lib/awk/*.c
This commit is contained in:
2011-12-21 06:40:27 +00:00
parent 42c44f9d3d
commit 38d3c22d1f
4 changed files with 69 additions and 49 deletions

View File

@ -423,32 +423,13 @@ static int recomp_record_fields (
* number of fields that the current record can hold,
* the field spaces are resized */
if (run->awk->mmgr->realloc != QSE_NULL)
tmp = QSE_AWK_REALLOC (
run->awk, run->inrec.flds,
QSE_SIZEOF(*run->inrec.flds) * max);
if (tmp == QSE_NULL)
{
tmp = QSE_AWK_REALLOC (
run->awk, run->inrec.flds,
QSE_SIZEOF(*run->inrec.flds) * max);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
}
else
{
tmp = QSE_AWK_ALLOC (
run->awk, QSE_SIZEOF(*run->inrec.flds) * max);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
if (run->inrec.flds != QSE_NULL)
{
QSE_MEMCPY (tmp, run->inrec.flds,
QSE_SIZEOF(*run->inrec.flds)*run->inrec.maxflds);
QSE_AWK_FREE (run->awk, run->inrec.flds);
}
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
run->inrec.flds = tmp;

View File

@ -6385,25 +6385,10 @@ static int __raw_push (qse_awk_rtx_t* run, void* val)
n = run->stack_limit + STACK_INCREMENT;
if (MMGR(run)->realloc != QSE_NULL)
{
tmp = (void**) QSE_AWK_REALLOC (
run->awk, run->stack, n * QSE_SIZEOF(void*));
if (tmp == QSE_NULL) return -1;
}
else
{
tmp = (void**) QSE_AWK_ALLOC (
run->awk, n * QSE_SIZEOF(void*));
if (tmp == QSE_NULL) return -1;
if (run->stack != QSE_NULL)
{
QSE_MEMCPY (
tmp, run->stack,
run->stack_limit * QSE_SIZEOF(void*));
QSE_AWK_FREE (run->awk, run->stack);
}
}
tmp = (void**) QSE_AWK_REALLOC (
run->awk, run->stack, n * QSE_SIZEOF(void*));
if (tmp == QSE_NULL) return -1;
run->stack = tmp;
run->stack_limit = n;
}