void extend_column_bindings(ARDFields *self, int num_columns) { CSTR func = "extend_column_bindings"; BindInfoClass *new_bindings; int i; mylog("%s: entering ... self=%p, bindings_allocated=%d, num_columns=%d\n", func, self, self->allocated, num_columns); /* * if we have too few, allocate room for more, and copy the old * entries into the new structure */ if (self->allocated < num_columns) { new_bindings = create_empty_bindings(num_columns); if (!new_bindings) { mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_columns, self->allocated); if (self->bindings) { free(self->bindings); self->bindings = NULL; } self->allocated = 0; return; } if (self->bindings) { for (i = 0; i < self->allocated; i++) new_bindings[i] = self->bindings[i]; free(self->bindings); } self->bindings = new_bindings; self->allocated = num_columns; } /* * There is no reason to zero out extra bindings if there are more * than needed. If an app has allocated extra bindings, let it worry * about it by unbinding those columns. */ /* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */ /* SQLExecDirect(...) # returns 5 cols */ /* SQLExecDirect(...) # returns 10 cols (now OK) */ mylog("exit %s=%p\n", func, self->bindings); }
void extend_bindings(StatementClass *stmt, int num_columns) { static char* const func="extend_bindings"; BindInfoClass *new_bindings; int i; mylog("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n", func, stmt, stmt->bindings_allocated, num_columns); /* if we have too few, allocate room for more, and copy the old */ /* entries into the new structure */ if(stmt->bindings_allocated < num_columns) { new_bindings = create_empty_bindings(num_columns); if ( ! new_bindings) { mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_columns, stmt->bindings_allocated); if (stmt->bindings) { free(stmt->bindings); stmt->bindings = NULL; } stmt->bindings_allocated = 0; return; } if(stmt->bindings) { for(i=0; i<stmt->bindings_allocated; i++) new_bindings[i] = stmt->bindings[i]; free(stmt->bindings); } stmt->bindings = new_bindings; stmt->bindings_allocated = num_columns; } /* There is no reason to zero out extra bindings if there are */ /* more than needed. If an app has allocated extra bindings, */ /* let it worry about it by unbinding those columns. */ /* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */ /* SQLExecDirect(...) # returns 5 cols */ /* SQLExecDirect(...) # returns 10 cols (now OK) */ mylog("exit extend_bindings\n"); }