updated mod-mysql.c and mod-uci.c for better styling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-04-22 21:35:40 +09:00
parent bea9b75fad
commit 5b4eac36af
2 changed files with 136 additions and 127 deletions

View File

@ -839,6 +839,7 @@ static int fnc_affected_rows (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{ {
my_ulonglong nrows; my_ulonglong nrows;
hawk_val_t* vrows; hawk_val_t* vrows;
int n;
ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node);
@ -856,10 +857,11 @@ static int fnc_affected_rows (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows) <= -1) hawk_rtx_refupval (rtx, vrows);
n = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows);
hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{ {
hawk_rtx_refupval (rtx, vrows);
hawk_rtx_refdownval (rtx, vrows);
take_rtx_err = 1; take_rtx_err = 1;
goto done; goto done;
} }
@ -885,6 +887,7 @@ static int fnc_insert_id (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{ {
my_ulonglong nrows; my_ulonglong nrows;
hawk_val_t* vrows; hawk_val_t* vrows;
int n;
ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node);
@ -902,10 +905,11 @@ static int fnc_insert_id (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows) <= -1) hawk_rtx_refupval (rtx, vrows);
n = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows);
hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{ {
hawk_rtx_refupval (rtx, vrows);
hawk_rtx_refdownval (rtx, vrows);
take_rtx_err = 1; take_rtx_err = 1;
goto done; goto done;
} }
@ -934,6 +938,7 @@ static int fnc_escape_string (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
if (sql_node) if (sql_node)
{ {
hawk_oow_t qlen; hawk_oow_t qlen;
int n;
a1 = hawk_rtx_getarg(rtx, 1); a1 = hawk_rtx_getarg(rtx, 1);
@ -953,10 +958,11 @@ static int fnc_escape_string (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv) <= -1) hawk_rtx_refupval (rtx, retv);
n = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv);
hawk_rtx_refdownval (rtx, retv);
if (n <= -1)
{ {
hawk_rtx_refupval (rtx, retv);
hawk_rtx_refdownval (rtx, retv);
take_rtx_err = 1; take_rtx_err = 1;
goto done; goto done;
} }
@ -1089,7 +1095,7 @@ static int fnc_fetch_row (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{ {
MYSQL_ROW row; MYSQL_ROW row;
unsigned int i; unsigned int i;
hawk_val_t* row_val; hawk_val_t* row_val, * tmp;
int x; int x;
row = mysql_fetch_row(res_node->res); row = mysql_fetch_row(res_node->res);
@ -1135,10 +1141,11 @@ static int fnc_fetch_row (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
key_len = hawk_int_to_oocstr(i, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf)); /* TOOD: change this function to hawk_rtx_intxxxxx */ key_len = hawk_int_to_oocstr(i, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf)); /* TOOD: change this function to hawk_rtx_intxxxxx */
HAWK_ASSERT (key_len != (hawk_oow_t)-1); HAWK_ASSERT (key_len != (hawk_oow_t)-1);
if (hawk_rtx_setmapvalfld(rtx, row_map, key_buf, key_len, row_val) == HAWK_NULL) hawk_rtx_refupval (rtx, row_val);
tmp = hawk_rtx_setmapvalfld(rtx, row_map, key_buf, key_len, row_val);
hawk_rtx_refdownval (rtx, row_val);
if (!tmp)
{ {
hawk_rtx_refupval (rtx, row_val);
hawk_rtx_refdownval (rtx, row_val);
take_rtx_err = 1; take_rtx_err = 1;
goto done; goto done;
} }
@ -1690,6 +1697,7 @@ static int fnc_stmt_affected_rows (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{ {
my_ulonglong nrows; my_ulonglong nrows;
hawk_val_t* vrows; hawk_val_t* vrows;
int n;
nrows = mysql_stmt_affected_rows(stmt_node->stmt); nrows = mysql_stmt_affected_rows(stmt_node->stmt);
@ -1700,10 +1708,11 @@ static int fnc_stmt_affected_rows (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows) <= -1) hawk_rtx_refupval (rtx, vrows);
n = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows);
hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{ {
hawk_rtx_refupval (rtx, vrows);
hawk_rtx_refdownval (rtx, vrows);
take_rtx_err = 1; take_rtx_err = 1;
goto done; goto done;
} }
@ -1733,6 +1742,7 @@ static int fnc_stmt_insert_id (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{ {
my_ulonglong nrows; my_ulonglong nrows;
hawk_val_t* vrows; hawk_val_t* vrows;
int n;
nrows = mysql_stmt_insert_id(stmt_node->stmt); nrows = mysql_stmt_insert_id(stmt_node->stmt);
@ -1743,10 +1753,11 @@ static int fnc_stmt_insert_id (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done; goto done;
} }
if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows) <= -1) hawk_rtx_refupval (rtx, vrows);
n = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows);
hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{ {
hawk_rtx_refupval (rtx, vrows);
hawk_rtx_refdownval (rtx, vrows);
take_rtx_err = 1; take_rtx_err = 1;
goto done; goto done;
} }

View File

@ -143,7 +143,7 @@ static void free_uctx_node (hawk_rtx_t* rtx, uctx_list_t* list, uctx_node_t* nod
{ {
/* destroy the actual node if the node to be freed has the /* destroy the actual node if the node to be freed has the
* highest id */ * highest id */
HAWK_MMGR_FREE (hawk_rtx_getmmgr(rtx), node); hawk_rtx_freemem(rtx, node);
list->map.high--; list->map.high--;
} }
else else
@ -161,17 +161,15 @@ static void free_uctx_node (hawk_rtx_t* rtx, uctx_list_t* list, uctx_node_t* nod
hawk_mmgr_t* mmgr; hawk_mmgr_t* mmgr;
uctx_node_t* curnode; uctx_node_t* curnode;
mmgr = hawk_rtx_getmmgr(rtx);
while (list->free) while (list->free)
{ {
curnode = list->free; curnode = list->free;
list->free = list->free->next; list->free = list->free->next;
HAWK_ASSERT (curnode->ctx == HAWK_NULL); HAWK_ASSERT (curnode->ctx == HAWK_NULL);
HAWK_MMGR_FREE (mmgr, curnode); hawk_rtx_freemem (rtx, curnode);
} }
HAWK_MMGR_FREE (mmgr, list->map.tab); hawk_rtx_freemem (rtx, list->map.tab);
list->map.high = 0; list->map.high = 0;
list->map.capa = 0; list->map.capa = 0;
list->map.tab = HAWK_NULL; list->map.tab = HAWK_NULL;
@ -573,7 +571,7 @@ static int getoption_byid (
md[1].type = HAWK_VAL_MAP_DATA_INT; md[1].type = HAWK_VAL_MAP_DATA_INT;
md[1].vptr = &count; md[1].vptr = &count;
map = hawk_rtx_makemapvalwithdata (rtx, md); map = hawk_rtx_makemapvalwithdata(rtx, md);
if (map) if (map)
{ {
count = 1; count = 1;
@ -585,7 +583,7 @@ static int getoption_byid (
hawk_char_t* kp; hawk_char_t* kp;
hawk_size_t kl; hawk_size_t kl;
fld = hawk_rtx_makestrvalwithmbs (rtx, tmp->name); fld = hawk_rtx_makestrvalwithbcstr(rtx, tmp->name);
if (!fld) if (!fld)
{ {
hawk_rtx_refupval (rtx, map); hawk_rtx_refupval (rtx, map);
@ -595,21 +593,21 @@ static int getoption_byid (
break; break;
} }
subsep = hawk_rtx_getsubsep (rtx); subsep = hawk_rtx_getsubsep(rtx);
k[0].ptr = HAWK_T("value"); k[0].ptr = HAWK_T("value");
k[0].len = 5; k[0].len = 5;
k[1].ptr = subsep->ptr; k[1].ptr = subsep->ptr;
k[1].len = subsep->len; k[1].len = subsep->len;
k[2].ptr = idxbuf; k[2].ptr = idxbuf;
k[2].len = hawk_fmtuintmax (idxbuf, HAWK_COUNTOF(idxbuf), count, 10, -1, HAWK_T('\0'), HAWK_NULL); k[2].len = hawk_fmtuintmax(idxbuf, HAWK_COUNTOF(idxbuf), count, 10, -1, HAWK_T('\0'), HAWK_NULL);
k[3].ptr = HAWK_NULL; k[3].ptr = HAWK_NULL;
k[3].len = 0; k[3].len = 0;
kp = hawk_wcstradup (k, &kl, hawk_rtx_getmmgr(rtx)); kp = hawk_wcstradup(k, &kl, hawk_rtx_getmmgr(rtx));
if (kp == HAWK_NULL || hawk_rtx_setmapvalfld (rtx, map, kp, kl, fld) == HAWK_NULL) if (kp == HAWK_NULL || hawk_rtx_setmapvalfld(rtx, map, kp, kl, fld) == HAWK_NULL)
{ {
if (kp) HAWK_MMGR_FREE (hawk_rtx_getmmgr(rtx), kp); if (kp) hawk_rtx_freemem (rtx, kp);
hawk_rtx_refupval (rtx, fld); hawk_rtx_refupval (rtx, fld);
hawk_rtx_refdownval (rtx, fld); hawk_rtx_refdownval (rtx, fld);
hawk_rtx_refupval (rtx, map); hawk_rtx_refupval (rtx, map);
@ -619,13 +617,13 @@ static int getoption_byid (
break; break;
} }
HAWK_MMGR_FREE (hawk_rtx_getmmgr(rtx), kp); hawk_rtx_freemem (rtx, kp);
count++; count++;
} }
if (map) if (map)
{ {
if (hawk_rtx_setrefval (rtx, ref, map) <= -1) if (hawk_rtx_setrefval(rtx, ref, map) <= -1)
{ {
hawk_rtx_refupval (rtx, map); hawk_rtx_refupval (rtx, map);
hawk_rtx_refdownval (rtx, map); hawk_rtx_refdownval (rtx, map);