diff bindings/python/pyadbmodule.c @ 719:e3f1cf653c30

wooo! direct insert works! at least for the rather limited cases I've tests. Bad news is that I seem to have found a rather nasty bug in the query code I wrote back in september. (segfaults around line 471 if the query returns no results...)
author map01bf
date Fri, 25 Jun 2010 09:08:56 +0000
parents 14568e432e73
children 2fad8cfdb2d8
line wrap: on
line diff
--- a/bindings/python/pyadbmodule.c	Thu Jun 24 16:38:32 2010 +0000
+++ b/bindings/python/pyadbmodule.c	Fri Jun 25 09:08:56 2010 +0000
@@ -211,30 +211,34 @@
 	//verify that the data to be inserted is the correct size for the database.
 	
 	ins = (adb_datum_t *)malloc(sizeof(adb_datum_t));
-	if (!PyArray_AsCArray(&features, &(ins->data), dims,  1, descr)){
+	if (PyArray_AsCArray(&features, &(ins->data), dims,  1, descr)){
 		PyErr_SetString(PyExc_RuntimeError, "Trouble expressing the feature np array as a C array.");
 		return NULL;
 	}
 	
 	if (power){
-		if (!PyArray_AsCArray(&power, &(ins->power), dims,  1, descr)){
+		if (PyArray_AsCArray(&power, &(ins->power), dims,  1, descr)){
 			PyErr_SetString(PyExc_RuntimeError, "Trouble expressing the power np array as a C array.");
 			return NULL;
 		}
+	}else{
+		ins->power=NULL;
 	}
 	
 	if (times){
-		if (!PyArray_AsCArray(&times, &(ins->times), dims,  1, descr)){
+		if (PyArray_AsCArray(&times, &(ins->times), dims,  1, descr)){
 			PyErr_SetString(PyExc_RuntimeError, "Trouble expressing the times np array as a C array.");
 			return NULL;
 		}
+	}else{
+		ins->times=NULL;
 	}
 	ins->key = key;
 	ins->nvectors = (uint32_t)nVect;
 	ins->dim = (uint32_t)nDims;
 	//printf("features::%s\npower::%s\nkey::%s\ntimes::%s\n", ins->features, ins->power, ins->key, ins->times);
 	ok = audiodb_insert_datum(current_db, ins);//(current_db, ins);
-	return PyBool_FromLong(ok-1);
+	return PyInt_FromLong(ok);
 	
 }