~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-2.0/field.cc

  • Committer: Brian Aker
  • Date: 2011-11-18 16:11:02 UTC
  • mto: (2463.1.1 drizzle-include)
  • mto: This revision was merged to the branch mainline in revision 2462.
  • Revision ID: brian@tangent.org-20111118161102-d1mbswn88iwc2iv1
Pass through refactoring.

Never throw exceptions from libraries. You can not have the assumption that in a driver that the above language can handle this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
drizzle_field_t drizzle_field_buffer(drizzle_result_st *result, size_t *total,
78
78
                                     drizzle_return_t *ret_ptr)
79
79
{
80
 
  drizzle_field_t field;
81
80
  size_t offset= 0;
82
81
  size_t size= 0;
83
82
 
84
 
  field= drizzle_field_read(result, &offset, &size, total, ret_ptr);
 
83
  drizzle_return_t unused;
 
84
  if (ret_ptr == NULL)
 
85
  {
 
86
    ret_ptr= &unused;
 
87
  }
 
88
 
 
89
  drizzle_field_t field= drizzle_field_read(result, &offset, &size, total, ret_ptr);
85
90
  if (*ret_ptr != DRIZZLE_RETURN_OK)
 
91
  {
86
92
    return NULL;
 
93
  }
87
94
 
88
95
  if (field == NULL)
89
96
  {
93
100
 
94
101
  if (result->field_buffer == NULL)
95
102
  {
96
 
    result->field_buffer= new drizzle_field_t_type[(*total) + 1];
 
103
    result->field_buffer= new (std::nothrow) drizzle_field_t_type[(*total) + 1];
 
104
 
 
105
    if (result->field_buffer == NULL)
 
106
    {
 
107
      *ret_ptr= DRIZZLE_RETURN_MEMORY;
 
108
      *total= 0;
 
109
      return NULL;
 
110
    }
97
111
  }
98
112
 
99
113
  memcpy(result->field_buffer + offset, field, size);
102
116
  {
103
117
    field= drizzle_field_read(result, &offset, &size, total, ret_ptr);
104
118
    if (*ret_ptr != DRIZZLE_RETURN_OK)
 
119
    {
105
120
      return NULL;
 
121
    }
106
122
 
107
123
    memcpy(result->field_buffer + offset, field, size);
108
124
  }