Skip to content

Commit 5a4f704

Browse files
committed
Use bind_buf instead of single allocations for null indicators
1 parent a039383 commit 5a4f704

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ibase_query.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ static void _php_ibase_free_xsqlda(XSQLDA *sqlda) /* {{{ */
7171
var = sqlda->sqlvar;
7272
for (i = 0; i < sqlda->sqld; i++, var++) {
7373
efree(var->sqldata);
74-
if (var->sqlind) {
75-
efree(var->sqlind);
76-
}
7774
}
7875
efree(sqlda);
7976
}
@@ -563,14 +560,15 @@ static int _php_ibase_bind_array(zval *val, char *buf, zend_ulong buf_size, /* {
563560
static int _php_ibase_bind(XSQLDA *sqlda, zval *b_vars, BIND_BUF *buf, /* {{{ */
564561
ibase_query *ib_query)
565562
{
563+
BIND_BUF *buf = ib_query->bind_buf;
566564
int i, array_cnt = 0, rv = SUCCESS;
567565

568566
for (i = 0; i < sqlda->sqld; ++i) { /* bound vars */
569567

570568
zval *b_var = &b_vars[i];
571569
XSQLVAR *var = &sqlda->sqlvar[i];
572570

573-
var->sqlind = &buf[i].sqlind;
571+
var->sqlind = &buf[i].nullind;
574572
var->sqldata = (void*)&buf[i].val;
575573

576574
/* check if a NULL should be inserted */
@@ -604,7 +602,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval *b_vars, BIND_BUF *buf, /* {{{ */
604602
if (! force_null) break;
605603

606604
case IS_NULL:
607-
buf[i].sqlind = -1;
605+
buf[i].nullind = -1;
608606

609607
if (var->sqltype & SQL_ARRAY) ++array_cnt;
610608

@@ -613,7 +611,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval *b_vars, BIND_BUF *buf, /* {{{ */
613611

614612
/* if we make it to this point, we must provide a value for the parameter */
615613

616-
buf[i].sqlind = 0;
614+
buf[i].nullind = 0;
617615

618616
switch (var->sqltype & ~1) {
619617
struct tm t;
@@ -737,7 +735,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval *b_vars, BIND_BUF *buf, /* {{{ */
737735
break;
738736
}
739737
case IS_NULL:
740-
buf[i].sqlind = -1;
738+
buf[i].nullind = -1;
741739
break;
742740
default:
743741
_php_ibase_module_error("Parameter %d: must be boolean", i+1);
@@ -865,7 +863,7 @@ static void _php_ibase_alloc_xsqlda_vars(XSQLDA *sqlda, ISC_SHORT *nullinds) /*
865863
} /* switch */
866864

867865
if (var->sqltype & 1) { /* sql NULL flag */
868-
var->sqlind = emalloc(sizeof(short));
866+
var->sqlind = &nullinds[i];
869867
} else {
870868
var->sqlind = NULL;
871869
}

0 commit comments

Comments
 (0)