summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2006-05-10 11:53:13 +0000
committerAndrey Hristov <andrey@php.net>2006-05-10 11:53:13 +0000
commitac97b77ed9b3ec175cb8150f6dbb2709666df2ff (patch)
tree78bae18d7e305a7478fc747baf3f99035885cfff /ext/mysqli/mysqli.c
parent0881dbd101bd685b0e7fe9964395f56965081b20 (diff)
downloadphp-git-ac97b77ed9b3ec175cb8150f6dbb2709666df2ff.tar.gz
Don't allocate 2 chunks of memory when one can fit. Reduces memory
fragmentation. There is one more place that fragments memory but it will complicate the ongoing Unicode upgrade of mysqli so leaving it away for now.
Diffstat (limited to 'ext/mysqli/mysqli.c')
-rw-r--r--ext/mysqli/mysqli.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 684cddf305..8f9b5119d4 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -69,10 +69,6 @@ void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type)
return;
}
- if (bbuf.is_null) {
- efree(bbuf.is_null);
- }
-
for (i=0; i < bbuf.var_cnt; i++) {
/* free temporary bind buffer */
@@ -89,9 +85,18 @@ void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type)
efree(bbuf.vars);
}
+ /*
+ Don't free bbuf.is_null for FETCH_RESULT since we have allocated
+ is_null and buf in one block so we free only buf, which is the beginning
+ of the block. When FETCH_SIMPLE then buf wasn't allocated together with
+ buf and we have to free it.
+ */
if (type == FETCH_RESULT) {
efree(bbuf.buf);
+ } else if (type == FETCH_SIMPLE){
+ efree(bbuf.is_null);
}
+
bbuf.var_cnt = 0;
return;
}