Logo Search packages:      
Sourcecode: freetds version File versions

unsigned char* tds_alloc_param_row ( TDSPARAMINFO info,
TDSCOLINFO curparam 
)

Add another field to row. Is assumed that last TDSCOLINFO contain information about this. Update also info structure.

Parameters:
info parameters info where is contained row
curparam parameter to retrieve size information
Returns:
NULL on failure or new row

Definition at line 217 of file mem.c.

References tds_column_info::column_offset, tds_column_info::column_size, tds_result_info::columns, tds_result_info::current_row, tds_result_info::null_info_size, tds_result_info::num_cols, tds_result_info::row_size, and tds_alloc_param_row().

Referenced by tds_alloc_param_row().

{
int null_size, remainder, i;
TDS_INT row_size;
unsigned char *row;

      null_size = (unsigned)(info->num_cols+(8*TDS_ALIGN_SIZE-1)) / 8u;
      null_size = null_size - null_size % TDS_ALIGN_SIZE;
      null_size -= info->null_info_size;
      if (null_size < 0) null_size = 0;

      curparam->column_offset = info->row_size;
      /* the +1 are needed for terminater... still required (freddy77) */
      row_size = info->row_size + curparam->column_size + 1 + null_size;
      remainder = row_size % TDS_ALIGN_SIZE; 
      if (remainder) row_size += (TDS_ALIGN_SIZE - remainder);

      /* make sure the row buffer is big enough */
      if (info->current_row) {
            row = (unsigned char*) realloc(info->current_row, row_size);
      } else {
            row = (unsigned char*) malloc(row_size);
      }
      if (!row) return NULL;
      info->current_row = row;
      info->row_size = row_size;

      /* expand null buffer */
      if (null_size) {
            memmove(row+info->null_info_size+null_size,
                  row+info->null_info_size,
                  row_size-null_size-info->null_info_size);
            memset(row+info->null_info_size,0,null_size);
            info->null_info_size += null_size;
            for(i=0;i<info->num_cols;++i) {
                  info->columns[i]->column_offset += null_size;
            }
      }

      return row;
}


Generated by  Doxygen 1.6.0   Back to index