Skip to content

Commit

Permalink
functions without a prototype are deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Jan 21, 2024
1 parent 7fc53e7 commit 4b3b9e6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
7 changes: 6 additions & 1 deletion common/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ void getopt_option_destroy(getopt_option_t *goo)
free(goo);
}

void getopt_option_destroy_void(void *goo)
{
getopt_option_destroy((getopt_option_t *)goo);
}

void getopt_destroy(getopt_t *gopt)
{
// free the extra arguments and container
Expand All @@ -94,7 +99,7 @@ void getopt_destroy(getopt_t *gopt)

// deep free of the getopt_option structs. Also frees key/values, so
// after this loop, hash tables will no longer work
zarray_vmap(gopt->options, getopt_option_destroy);
zarray_vmap(gopt->options, getopt_option_destroy_void);
zarray_destroy(gopt->options);

// free tables
Expand Down
1 change: 1 addition & 0 deletions common/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef struct getopt getopt_t;

getopt_t *getopt_create();
void getopt_destroy(getopt_t *gopt);
void getopt_option_destroy_void(void *goo);

// Parse args. Returns 1 on success
int getopt_parse(getopt_t *gopt, int argc, char *argv[], int showErrors);
Expand Down
2 changes: 1 addition & 1 deletion common/zarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int zstrcmp(const void * a_pp, const void * b_pp)
return strcmp(a,b);
}

void zarray_vmap(zarray_t *za, void (*f)())
void zarray_vmap(zarray_t *za, void (*f)(void*))
{
assert(za != NULL);
assert(f != NULL);
Expand Down
2 changes: 1 addition & 1 deletion common/zarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static inline void zarray_map(zarray_t *za, void (*f)(void*))
*
* void map_function(element_type *element)
*/
void zarray_vmap(zarray_t *za, void (*f)());
void zarray_vmap(zarray_t *za, void (*f)(void *));

/**
* Removes all elements from the array and sets its size to zero. Pointers to
Expand Down
8 changes: 4 additions & 4 deletions common/zhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void zhash_iterator_remove(zhash_iterator_t *zit)
zit->last_entry--;
}

void zhash_map_keys(zhash_t *zh, void (*f)())
void zhash_map_keys(zhash_t *zh, void (*f)(void*))
{
assert(zh != NULL);
if (f == NULL)
Expand All @@ -368,7 +368,7 @@ void zhash_map_keys(zhash_t *zh, void (*f)())
}
}

void zhash_vmap_keys(zhash_t * zh, void (*f)())
void zhash_vmap_keys(zhash_t * zh, void (*f)(void*))
{
assert(zh != NULL);
if (f == NULL)
Expand All @@ -385,7 +385,7 @@ void zhash_vmap_keys(zhash_t * zh, void (*f)())
}
}

void zhash_map_values(zhash_t * zh, void (*f)())
void zhash_map_values(zhash_t * zh, void (*f)(void*))
{
assert(zh != NULL);
if (f == NULL)
Expand All @@ -400,7 +400,7 @@ void zhash_map_values(zhash_t * zh, void (*f)())
}
}

void zhash_vmap_values(zhash_t * zh, void (*f)())
void zhash_vmap_values(zhash_t * zh, void (*f)(void*))
{
assert(zh != NULL);
if (f == NULL)
Expand Down
8 changes: 4 additions & 4 deletions common/zhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ void zhash_iterator_remove(zhash_iterator_t *zit);
* for the key, which the caller should not modify, as the hash table will not be
* re-indexed. The function may be NULL, in which case no action is taken.
*/
void zhash_map_keys(zhash_t *zh, void (*f)());
void zhash_map_keys(zhash_t *zh, void (*f)(void *));

/**
* Calls the supplied function with a pointer to every value in the hash table in
* turn. The function will be passed a pointer to the table's internal storage
* for the value, which the caller may safely modify. The function may be NULL,
* in which case no action is taken.
*/
void zhash_map_values(zhash_t *zh, void (*f)());
void zhash_map_values(zhash_t *zh, void (*f)(void *));

/**
* Calls the supplied function with a copy of every key in the hash table in
Expand All @@ -280,7 +280,7 @@ void zhash_map_values(zhash_t *zh, void (*f)());
* Use with non-pointer keys (i.e. integer, double, etc.) will likely cause a
* segmentation fault.
*/
void zhash_vmap_keys(zhash_t *vh, void (*f)());
void zhash_vmap_keys(zhash_t *vh, void (*f)(void *));

/**
* Calls the supplied function with a copy of every value in the hash table in
Expand All @@ -293,7 +293,7 @@ void zhash_vmap_keys(zhash_t *vh, void (*f)());
* Use with non-pointer values (i.e. integer, double, etc.) will likely cause a
* segmentation fault.
*/
void zhash_vmap_values(zhash_t *vh, void (*f)());
void zhash_vmap_values(zhash_t *vh, void (*f)(void *));

/**
* Returns an array which contains copies of all of the hash table's keys, in no
Expand Down
2 changes: 1 addition & 1 deletion common/zmaxheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void zmaxheap_add(zmaxheap_t *heap, void *p, float v)
}
}

void zmaxheap_vmap(zmaxheap_t *heap, void (*f)())
void zmaxheap_vmap(zmaxheap_t *heap, void (*f)(void*))
{
assert(heap != NULL);
assert(f != NULL);
Expand Down
2 changes: 1 addition & 1 deletion common/zmaxheap.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct zmaxheap_iterator {

zmaxheap_t *zmaxheap_create(size_t el_sz);

void zmaxheap_vmap(zmaxheap_t *heap, void (*f)());
void zmaxheap_vmap(zmaxheap_t *heap, void (*f)(void *));

void zmaxheap_destroy(zmaxheap_t *heap);

Expand Down

0 comments on commit 4b3b9e6

Please sign in to comment.