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:
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user