~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/array.cc

  • Committer: Monty Taylor
  • Date: 2008-12-07 23:42:51 UTC
  • mto: This revision was merged to the branch mainline in revision 670.
  • Revision ID: monty@inaugust.com-20081207234251-yxtbg06jpylwej29
Finally removed all of the my_malloc stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
        In this senerio, the buffer is statically preallocated,
138
138
        so we have to create an all-new malloc since we overflowed
139
139
      */
140
 
      if (!(new_ptr= (char *) my_malloc((array->max_element+
141
 
                                         array->alloc_increment) *
142
 
                                        array->size_of_element,
143
 
                                        MYF(MY_WME))))
 
140
      if (!(new_ptr= (char *) malloc((array->max_element+
 
141
                                     array->alloc_increment) *
 
142
                                     array->size_of_element)))
144
143
        return 0;
145
144
      memcpy(new_ptr, array->buffer,
146
145
             array->elements * array->size_of_element);
147
146
    }
148
 
    else
149
 
    if (!(new_ptr=(char*) my_realloc(array->buffer,(array->max_element+
150
 
                                     array->alloc_increment)*
151
 
                                     array->size_of_element,
152
 
                                     MYF(MY_WME | MY_ALLOW_ZERO_PTR))))
 
147
    else if (!(new_ptr=
 
148
             (array->buffer) ? (char*) realloc(array->buffer,
 
149
                                               (array->max_element+
 
150
                                                array->alloc_increment)*
 
151
                                                array->size_of_element)
 
152
                             : (char*) malloc((array->max_element+
 
153
                                              array->alloc_increment)*
 
154
                                              array->size_of_element)))
153
155
      return 0;
154
156
    array->buffer= (unsigned char*) new_ptr;
155
157
    array->max_element+=array->alloc_increment;
241
243
         In this senerio, the buffer is statically preallocated,
242
244
         so we have to create an all-new malloc since we overflowed
243
245
       */
244
 
       if (!(new_ptr= (unsigned char *) my_malloc(size *
245
 
                                         array->size_of_element,
246
 
                                         MYF(MY_WME))))
 
246
       if (!(new_ptr= (unsigned char *) malloc(size *
 
247
                                               array->size_of_element)))
247
248
         return 0;
248
249
       memcpy(new_ptr, array->buffer,
249
250
              array->elements * array->size_of_element);
251
252
     else
252
253
 
253
254
 
254
 
    if (!(new_ptr= (unsigned char*) my_realloc(array->buffer,size*
255
 
                                       array->size_of_element,
256
 
                                       MYF(MY_WME | MY_ALLOW_ZERO_PTR))))
 
255
    if (!(new_ptr=
 
256
           (array->buffer)
 
257
             ? (unsigned char*) realloc(array->buffer,
 
258
                                        size* array->size_of_element)
 
259
             : (unsigned char*) malloc(size* array->size_of_element)))
257
260
      return true;
258
261
    array->buffer= new_ptr;
259
262
    array->max_element= size;
347
350
 
348
351
  if (array->buffer && array->max_element != elements)
349
352
  {
350
 
    array->buffer=(unsigned char*) my_realloc(array->buffer,
351
 
                                     elements*array->size_of_element,
352
 
                                     MYF(MY_WME));
 
353
    array->buffer=(unsigned char*) realloc(array->buffer,
 
354
                                     elements*array->size_of_element);
353
355
    array->max_element=elements;
354
356
  }
355
357
}