Use simple free function in pa_dynarray_free

This commit is contained in:
Maarten Bosmans 2011-11-18 09:58:08 +01:00 committed by Colin Guthrie
parent 46920bab16
commit e45b02de55
4 changed files with 6 additions and 10 deletions

View file

@ -1800,7 +1800,7 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
sorted_files = pa_xnew(char*, count); sorted_files = pa_xnew(char*, count);
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
sorted_files[i] = pa_dynarray_get(files, i); sorted_files[i] = pa_dynarray_get(files, i);
pa_dynarray_free(files, NULL, NULL); pa_dynarray_free(files, NULL);
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
for (unsigned j = 0; j < count; ++j) { for (unsigned j = 0; j < count; ++j) {

View file

@ -50,14 +50,14 @@ pa_dynarray* pa_dynarray_new(void) {
return a; return a;
} }
void pa_dynarray_free(pa_dynarray* a, pa_free2_cb_t free_func, void *userdata) { void pa_dynarray_free(pa_dynarray *a, pa_free_cb_t free_func) {
unsigned i; unsigned i;
pa_assert(a); pa_assert(a);
if (free_func) if (free_func)
for (i = 0; i < a->n_entries; i++) for (i = 0; i < a->n_entries; i++)
if (a->data[i]) if (a->data[i])
free_func(a->data[i], userdata); free_func(a->data[i]);
pa_xfree(a->data); pa_xfree(a->data);
pa_xfree(a); pa_xfree(a);

View file

@ -22,7 +22,7 @@
USA. USA.
***/ ***/
#include <pulsecore/idxset.h> #include <pulse/def.h>
typedef struct pa_dynarray pa_dynarray; typedef struct pa_dynarray pa_dynarray;
@ -34,7 +34,7 @@ pa_dynarray* pa_dynarray_new(void);
/* Free the array calling the specified function for every entry in /* Free the array calling the specified function for every entry in
* the array. The function may be NULL. */ * the array. The function may be NULL. */
void pa_dynarray_free(pa_dynarray* a, pa_free2_cb_t free_func, void *userdata); void pa_dynarray_free(pa_dynarray *a, pa_free_cb_t free_func);
/* Store p at position i in the array */ /* Store p at position i in the array */
void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p); void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p);

View file

@ -33,10 +33,6 @@
#include "tokenizer.h" #include "tokenizer.h"
static void token_free(void *p, void *userdata) {
pa_xfree(p);
}
static void parse(pa_dynarray*a, const char *s, unsigned args) { static void parse(pa_dynarray*a, const char *s, unsigned args) {
int infty = 0; int infty = 0;
const char delimiter[] = " \t\n\r"; const char delimiter[] = " \t\n\r";
@ -76,7 +72,7 @@ void pa_tokenizer_free(pa_tokenizer *t) {
pa_dynarray *a = (pa_dynarray*) t; pa_dynarray *a = (pa_dynarray*) t;
pa_assert(a); pa_assert(a);
pa_dynarray_free(a, token_free, NULL); pa_dynarray_free(a, pa_xfree);
} }
const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i) { const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i) {