minor code refactoring
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-08-02 14:50:38 +09:00
parent 2c63c56e0e
commit 17b0dfcee3
4 changed files with 84 additions and 81 deletions

View File

@ -466,8 +466,9 @@ static void stop_run (int signo)
#endif
}
static void do_nothing (int unucut)
static void do_nothing (int unused)
{
/* do nothing */
}
static void set_intr_run (void)

View File

@ -105,7 +105,6 @@ struct xarg_t
struct arg_t
{
int incl_conv;
hawk_parsestd_t* psin; /* input source streams */
hawk_bch_t* osf; /* output source file */
xarg_t icf; /* input console files */
@ -377,7 +376,7 @@ static int add_gvs_to_hawk (hawk_t* hawk, arg_t* arg)
return 0;
}
static int apply_fs_and_gvs_to_rtx (hawk_rtx_t* rtx, arg_t* arg)
static int apply_fs_and_gvs_to_rtx (hawk_rtx_t* rtx, const arg_t* arg)
{
hawk_oow_t i;
@ -399,8 +398,6 @@ static int apply_fs_and_gvs_to_rtx (hawk_rtx_t* rtx, arg_t* arg)
{
/* set the value of user-defined global variables
* to a runtime context */
hawk_oow_t i;
for (i = 0; i < arg->gvm.size; i++)
{
hawk_val_t* v;
@ -825,8 +822,6 @@ static int process_argv (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_ar
case '\0':
{
/* a long option with no corresponding short option */
hawk_oow_t i;
if (hawk_comp_bcstr(opt.lngopt, "script-encoding", 0) == 0)
{
arg->script_cmgr = hawk_get_cmgr_by_bcstr(opt.arg);
@ -949,23 +944,14 @@ oops:
if (arg->gvm.ptr) free(arg->gvm.ptr);
purge_xarg(&arg->icf);
purge_xarg(&arg->ocf);
if (isf)
{
if (arg->incl_conv) free (isf[0].u.bcs.ptr);
free (isf);
}
if (isf) free(isf);
return oops_ret;
}
static void freearg (struct arg_t* arg)
{
if (arg->psin)
{
if (arg->incl_conv) free (arg->psin[0].u.bcs.ptr);
free (arg->psin);
}
/*if (arg->osf != HAWK_NULL) free (arg->osf);*/
if (arg->psin) free(arg->psin);
/*if (arg->osf) free(arg->osf);*/
purge_xarg (&arg->icf);
purge_xarg (&arg->ocf);
if (arg->gvm.ptr) free(arg->gvm.ptr);

View File

@ -196,8 +196,24 @@ static HAWK_INLINE hawk_oow_t szlog2 (hawk_oow_t n)
static HAWK_INLINE hawk_oow_t getxfi (hawk_xma_t* xma, hawk_oow_t size)
{
/* if the aligned size is below the first threshold(FIXED)
* the slot to the xma->xfree field is the aligned size itself.
* For example, assuming ALIGN is 8, size 117 produces xfi 13. ((117 / 8) - 1) */
hawk_oow_t xfi = ((size) / ALIGN) - 1;
/* If the caculated index is greater than or equal to the threshold,
* each slot in the xfree field will span across a wider range of sizes.
* Roughly, like this. but all these values are dependent on ALIGN.
* Words-1 Size XFI
* 32~62 264~511 => 32
* 63~126 512~1023 => 33
* 127~254 1024~2047 => 34
* 255~510 2048~4095 => 35
* ....
*/
if (xfi >= FIXED) xfi = szlog2(size) - (xma)->bdec + FIXED;
/* The very large size is place at the last index */
if (xfi > XFIMAX(xma)) xfi = XFIMAX(xma);
return xfi;
}