comparison bindings/python/pyadbmodule.c @ 751:98d2e1de11bb

Fixed array boundary error on 1d array retrieval
author mas01mc
date Thu, 25 Nov 2010 02:30:53 +0000
parents d93292ae7c1b
children 9d32eea0cd78
comparison
equal deleted inserted replaced
750:d93292ae7c1b 751:98d2e1de11bb
1009 } 1009 }
1010 1010
1011 if(features){ 1011 if(features){
1012 if(ins->dim>1){ 1012 if(ins->dim>1){
1013 dims=2; 1013 dims=2;
1014 shape[1]= ins->dim; 1014 shape[1]= ins->dim;
1015 } 1015 }
1016 else{ 1016 else{
1017 dims=1; 1017 dims=1;
1018 } 1018 }
1019 shape[0]= ins->nvectors; 1019 shape[0]= ins->nvectors;
1040 } 1040 }
1041 1041
1042 /* Copy the data, this allows us to free the allocated memory and let 1042 /* Copy the data, this allows us to free the allocated memory and let
1043 * python do the subsequent garbage collection itself. 1043 * python do the subsequent garbage collection itself.
1044 */ 1044 */
1045 int num_items = ins->nvectors * ins->dim; 1045 int num_items = ins->nvectors;
1046 if(dims>1){
1047 num_items *= shape[1];
1048 }
1046 double* p = (double*) PyArray_DATA(outgoing); 1049 double* p = (double*) PyArray_DATA(outgoing);
1047 double* d = data; 1050 double* d = data;
1048 while(num_items--) 1051 while(num_items--)
1049 *p++ = *d++; 1052 *p++ = *d++;
1050 audiodb_free_datum(current_db, ins); // free the source audiodb_datum 1053 audiodb_free_datum(current_db, ins); // free the source audiodb_datum