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); 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); hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{
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); 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); hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{
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); 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); hawk_rtx_refdownval (rtx, retv);
if (n <= -1)
{
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); 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); hawk_rtx_refdownval (rtx, row_val);
if (!tmp)
{
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); 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); hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{
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); 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); hawk_rtx_refdownval (rtx, vrows);
if (n <= -1)
{
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;
@ -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);
@ -609,7 +607,7 @@ static int getoption_byid (
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,7 +617,7 @@ static int getoption_byid (
break; break;
} }
HAWK_MMGR_FREE (hawk_rtx_getmmgr(rtx), kp); hawk_rtx_freemem (rtx, kp);
count++; count++;
} }