[pulseaudio-discuss] [PATCH 1/2] Use simple free function in pa_dynarray_free
Maarten Bosmans
mkbosmans at gmail.com
Fri Nov 18 00:58:08 PST 2011
---
src/pulsecore/cli-command.c | 2 +-
src/pulsecore/dynarray.c | 4 ++--
src/pulsecore/dynarray.h | 4 ++--
src/pulsecore/tokenizer.c | 6 +-----
4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index c38637d..a43b7ca 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -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);
for (i = 0; i < count; ++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 (unsigned j = 0; j < count; ++j) {
diff --git a/src/pulsecore/dynarray.c b/src/pulsecore/dynarray.c
index 69d835a..78b2eb9 100644
--- a/src/pulsecore/dynarray.c
+++ b/src/pulsecore/dynarray.c
@@ -50,14 +50,14 @@ pa_dynarray* pa_dynarray_new(void) {
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;
pa_assert(a);
if (free_func)
for (i = 0; i < a->n_entries; i++)
if (a->data[i])
- free_func(a->data[i], userdata);
+ free_func(a->data[i]);
pa_xfree(a->data);
pa_xfree(a);
diff --git a/src/pulsecore/dynarray.h b/src/pulsecore/dynarray.h
index 9a8e64e..70deebb 100644
--- a/src/pulsecore/dynarray.h
+++ b/src/pulsecore/dynarray.h
@@ -22,7 +22,7 @@
USA.
***/
-#include <pulsecore/idxset.h>
+#include <pulse/def.h>
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
* 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 */
void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p);
diff --git a/src/pulsecore/tokenizer.c b/src/pulsecore/tokenizer.c
index a0ade69..cb682d6 100644
--- a/src/pulsecore/tokenizer.c
+++ b/src/pulsecore/tokenizer.c
@@ -33,10 +33,6 @@
#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) {
int infty = 0;
const char delimiter[] = " \t\n\r";
@@ -76,7 +72,7 @@ void pa_tokenizer_free(pa_tokenizer *t) {
pa_dynarray *a = (pa_dynarray*) t;
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) {
--
1.7.4.1
More information about the pulseaudio-discuss
mailing list