~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/field.cc

  • Committer: Mark Atwood
  • Date: 2011-12-16 15:35:52 UTC
  • mfrom: (2472.1.1 drizzle-build)
  • Revision ID: me@mark.atwood.name-20111216153552-0zk0mmf1tt22p92n
mergeĀ lp:~brianaker/drizzle/libdrizzle-valgrind-test-warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
 
1
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
2
 *
2
3
 * Drizzle Client & Protocol Library
3
4
 *
4
5
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
61
62
  }
62
63
 
63
64
  *ret_ptr= drizzle_state_loop(result->con);
64
 
  if (*ret_ptr == DRIZZLE_RETURN_OK &&
 
65
  if (*ret_ptr == DRIZZLE_RETURN_OK and
65
66
      result->options & DRIZZLE_RESULT_ROW_BREAK)
66
67
  {
67
68
    *ret_ptr= DRIZZLE_RETURN_ROW_BREAK;
77
78
drizzle_field_t drizzle_field_buffer(drizzle_result_st *result, size_t *total,
78
79
                                     drizzle_return_t *ret_ptr)
79
80
{
80
 
  drizzle_field_t field;
81
81
  size_t offset= 0;
82
82
  size_t size= 0;
83
83
 
84
 
  field= drizzle_field_read(result, &offset, &size, total, ret_ptr);
 
84
  drizzle_field_t field= drizzle_field_read(result, &offset, &size, total, ret_ptr);
 
85
 
85
86
  if (*ret_ptr != DRIZZLE_RETURN_OK)
 
87
  {
86
88
    return NULL;
 
89
  }
87
90
 
88
91
  if (field == NULL)
89
92
  {
108
111
  {
109
112
    field= drizzle_field_read(result, &offset, &size, total, ret_ptr);
110
113
    if (*ret_ptr != DRIZZLE_RETURN_OK)
 
114
    {
111
115
      return NULL;
 
116
    }
112
117
 
113
118
    memcpy(result->field_buffer + offset, field, size);
114
119
  }
122
127
 
123
128
void drizzle_field_free(drizzle_field_t field)
124
129
{
125
 
  free(field);
 
130
  if (field)
 
131
  {
 
132
    free(field);
 
133
  }
126
134
}
127
135
 
128
136
/*
287
295
  drizzle_log_debug(con->drizzle, "drizzle_state_field_write");
288
296
 
289
297
  if (result->field == NULL && result->field_total != 0)
 
298
  {
290
299
    return DRIZZLE_RETURN_PAUSE;
 
300
  }
291
301
 
292
302
  free_size= (size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer);
293
303
  ptr= start;
335
345
    result->field= NULL;
336
346
 
337
347
    if (result->field_offset == result->field_total)
 
348
    {
338
349
      drizzle_state_pop(con);
 
350
    }
339
351
    else if (con->packet_size == 0)
340
352
    {
341
353
      con->result->options|= DRIZZLE_RESULT_ROW_BREAK;
343
355
    }
344
356
 
345
357
    drizzle_state_push(con, drizzle_state_write);
 
358
 
346
359
    return DRIZZLE_RETURN_OK;
347
360
  }
348
361
 
349
362
  if (result->field_size == 0)
 
363
  {
350
364
    drizzle_state_pop(con);
 
365
  }
351
366
  else
352
367
  {
353
368
    if (result->field_size < free_size)