~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/array.cc

  • Committer: Brian Aker
  • Date: 2008-12-06 23:57:32 UTC
  • mfrom: (656.1.10 devel)
  • Revision ID: brian@tangent.org-20081206235732-jx228bczpvmxu8ww
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
      alloc_increment   Increment for adding new elements
31
31
 
32
32
  DESCRIPTION
33
 
    init_dynamic_array() initiates array and allocate space for 
34
 
    init_alloc eilements. 
 
33
    init_dynamic_array() initiates array and allocate space for
 
34
    init_alloc eilements.
35
35
    Array is usable even if space allocation failed.
36
36
    Static buffers must begin immediately after the array structure.
37
37
 
41
41
*/
42
42
 
43
43
bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint32_t element_size,
44
 
                            void *init_buffer, uint32_t init_alloc, 
 
44
                            void *init_buffer, uint32_t init_alloc,
45
45
                            uint32_t alloc_increment)
46
46
{
47
47
  if (!alloc_increment)
69
69
    return(true);
70
70
  }
71
71
  return(false);
72
 
 
72
}
73
73
 
74
74
bool init_dynamic_array(DYNAMIC_ARRAY *array, uint32_t element_size,
75
 
                           uint32_t init_alloc, 
 
75
                           uint32_t init_alloc,
76
76
                           uint32_t alloc_increment)
77
77
{
78
78
  /* placeholder to preserve ABI */
79
 
  return my_init_dynamic_array_ci(array, element_size, init_alloc, 
 
79
  return my_init_dynamic_array_ci(array, element_size, init_alloc,
80
80
                                  alloc_increment);
81
81
}
82
82
/*
111
111
 
112
112
 
113
113
/*
114
 
  Alloc space for next element(s) 
 
114
  Alloc space for next element(s)
115
115
 
116
116
  SYNOPSIS
117
117
    alloc_dynamic()
143
143
                                        array->size_of_element,
144
144
                                        MYF(MY_WME))))
145
145
        return 0;
146
 
      memcpy(new_ptr, array->buffer, 
 
146
      memcpy(new_ptr, array->buffer,
147
147
             array->elements * array->size_of_element);
148
148
    }
149
149
    else
165
165
  SYNOPSIS
166
166
    pop_dynamic()
167
167
      array
168
 
  
169
 
  RETURN VALUE    
 
168
 
 
169
  RETURN VALUE
170
170
    pointer     Ok
171
171
    0           Array is empty
172
172
*/
188
188
      idx       Index where element is to be inserted
189
189
 
190
190
  DESCRIPTION
191
 
    set_dynamic() replaces element in array. 
192
 
    If idx > max_element insert new element. Allocate memory if needed. 
193
 
 
 
191
    set_dynamic() replaces element in array.
 
192
    If idx > max_element insert new element. Allocate memory if needed.
 
193
 
194
194
  RETURN VALUE
195
195
    true        Idx was out of range and allocation of new memory failed
196
196
    false       Ok
246
246
                                         array->size_of_element,
247
247
                                         MYF(MY_WME))))
248
248
         return 0;
249
 
       memcpy(new_ptr, array->buffer, 
 
249
       memcpy(new_ptr, array->buffer,
250
250
              array->elements * array->size_of_element);
251
251
     }
252
252
     else
268
268
 
269
269
  SYNOPSIS
270
270
    get_dynamic()
271
 
      array     
 
271
      array
272
272
      unsigned char*    Element to be returned. If idx > elements contain zeroes.
273
 
      idx       Index of element wanted. 
 
273
      idx       Index of element wanted.
274
274
*/
275
275
 
276
276
void get_dynamic(DYNAMIC_ARRAY *array, unsigned char* element, uint32_t idx)
345
345
  */
346
346
  if (array->buffer == (unsigned char *)(array + 1))
347
347
    return;
348
 
    
 
348
 
349
349
  if (array->buffer && array->max_element != elements)
350
350
  {
351
351
    array->buffer=(unsigned char*) my_realloc(array->buffer,
362
362
  SYNOPSIS
363
363
    get_index_dynamic()
364
364
     array      Array
365
 
     element Whose element index 
 
365
     element Whose element index
366
366
 
367
367
*/
368
368