Commit 6f0d04f0 by Orlando Vazquez

Don't free bind_req->pair values if there are none.

parent 9fae3abd
...@@ -89,16 +89,14 @@ function _doStep(db, statement, rowCallback) { ...@@ -89,16 +89,14 @@ function _doStep(db, statement, rowCallback) {
} }
function _onPrepare(db, statement, bindings, rowCallback) { function _onPrepare(db, statement, bindings, rowCallback) {
if (Array.isArray(bindings)) { function next() {
if (bindings.length) {
_setBindingsByIndex(db, statement, bindings, _doStep, rowCallback);
}
else {
_doStep(db, statement, rowCallback); _doStep(db, statement, rowCallback);
} }
if (Array.isArray(bindings)) {
statement.bindArray(bindings, next);
} }
else if (typeof(bindings) !== 'undefined') { else if (typeof(bindings) === 'object') {
// TODO index by keys statement.bindObject(bindings, next);
} }
} }
......
...@@ -79,8 +79,11 @@ int Statement::EIO_AfterBindArray(eio_req *req) { ...@@ -79,8 +79,11 @@ int Statement::EIO_AfterBindArray(eio_req *req) {
bind_req->cb.Dispose(); bind_req->cb.Dispose();
free(bind_req->pairs->key);; if (bind_req->len) {
free(bind_req->pairs->key);
free(bind_req->pairs->value); free(bind_req->pairs->value);
}
free(bind_req->pairs); free(bind_req->pairs);
free(bind_req); free(bind_req);
...@@ -259,6 +262,7 @@ Handle<Value> Statement::BindArray(const Arguments& args) { ...@@ -259,6 +262,7 @@ Handle<Value> Statement::BindArray(const Arguments& args) {
// setup value // setup value
if (val->IsInt32()) { if (val->IsInt32()) {
printf("Binding int\n");
pairs->value_type = VALUE_INT; pairs->value_type = VALUE_INT;
int *value = (int *) malloc(sizeof(int)); int *value = (int *) malloc(sizeof(int));
*value = val->Int32Value(); *value = val->Int32Value();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment