/* This program is free software; you can redistribute it and/or modify it
under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
under the terms of the license (GNU LGPL) which comes with this package. */
_gras_dynar_expand(gras_dynar_t * const dynar,
const int nb) {
gras_error_t errcode = no_error;
_gras_dynar_expand(gras_dynar_t * const dynar,
const int nb) {
gras_error_t errcode = no_error;
- const size_t new_size = nb > (2*(old_size+1)) ? nb : (2*(old_size+1));
- const size_t new_length = new_size*elmsize;
+ const unsigned long new_size = nb > (2*(old_size+1)) ? nb : (2*(old_size+1));
+ const unsigned long new_length = new_size*elmsize;
char * const new_data = gras_malloc0(elmsize*new_size);
DEBUG3("expend %p from %lu to %d elements", (void*)dynar, (unsigned long)old_size, nb);
char * const new_data = gras_malloc0(elmsize*new_size);
DEBUG3("expend %p from %lu to %d elements", (void*)dynar, (unsigned long)old_size, nb);
void
_gras_dynar_get_elm(void * const dst,
const gras_dynar_t * const dynar,
void
_gras_dynar_get_elm(void * const dst,
const gras_dynar_t * const dynar,
const void * const src) {
void * const elm = _gras_dynar_elm(dynar, idx);
const void * const src) {
void * const elm = _gras_dynar_elm(dynar, idx);
* @elm_size: size of each element in the dynar
* @free_func: function to call each time we want to get rid of an element (or NULL if nothing to do).
*
* @elm_size: size of each element in the dynar
* @free_func: function to call each time we want to get rid of an element (or NULL if nothing to do).
*
* pointer of pointer. That is to say that dynars can contain either base
* types (int, char, double, etc) or pointer of pointers (struct **).
*/
* pointer of pointer. That is to say that dynars can contain either base
* types (int, char, double, etc) or pointer of pointers (struct **).
*/
-void
-gras_dynar_new(gras_dynar_t ** const p_dynar,
- const size_t elmsize,
- void_f_pvoid_t * const free_func) {
+gras_dynar_t *
+gras_dynar_new(const unsigned long elmsize,
+ void_f_pvoid_t * const free_func) {
void * const elm_src = _gras_dynar_elm(dynar, idx);
void * const elm_dst = _gras_dynar_elm(dynar, idx+1);
void * const elm_src = _gras_dynar_elm(dynar, idx);
void * const elm_dst = _gras_dynar_elm(dynar, idx+1);
void * const elm_src = _gras_dynar_elm(dynar, idx+1);
void * const elm_dst = _gras_dynar_elm(dynar, idx);
void * const elm_src = _gras_dynar_elm(dynar, idx+1);
void * const elm_dst = _gras_dynar_elm(dynar, idx);
for (i = 0; i < used; i++) {
_gras_dynar_get_elm(elm, dynar, i);
for (i = 0; i < used; i++) {
_gras_dynar_get_elm(elm, dynar, i);