diff options
author | Jan Klemkow <web2p10@wemelug.de> | 2010-07-09 00:55:02 +0200 |
---|---|---|
committer | Jan Klemkow <web2p10@wemelug.de> | 2010-07-09 00:55:02 +0200 |
commit | 21b1027832ff5e53edc37dd9f5c153217a65b6fd (patch) | |
tree | 156d666ade9380434ecae73f9bd02fe71e2d2caf /sink_input.c | |
parent | 83a220ec9b1fe7e706478bc1604fe8741be649a2 (diff) | |
download | pa-sink-ctl-21b1027832ff5e53edc37dd9f5c153217a65b6fd.tar.gz pa-sink-ctl-21b1027832ff5e53edc37dd9f5c153217a65b6fd.tar.bz2 pa-sink-ctl-21b1027832ff5e53edc37dd9f5c153217a65b6fd.zip |
wip: cleanup sink & co.
Diffstat (limited to 'sink_input.c')
-rw-r--r-- | sink_input.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/sink_input.c b/sink_input.c index 1a6eda2..54f7c04 100644 --- a/sink_input.c +++ b/sink_input.c @@ -24,10 +24,26 @@ void sink_input_clear(sink_input_info* sink_input) { free(sink_input->pid); free(sink_input); + sink_input = NULL; } -void sink_input_list_init(sink_input_info** sink_input_list, int max) { - sink_input_list = (sink_input_info**) calloc(max, sizeof(sink_input_info*)); +sink_input_info** sink_input_list_init(int max) { + + sink_input_info** sink_input_list = (sink_input_info**) calloc(max, sizeof(sink_input_info*)); + + for (int i = 0; i < max; ++i) + sink_input_list = NULL; + + return sink_input_list; +} + +void sink_input_list_enlarge(sink_input_info** sink_input_list, int* max, int counter) { + + (*max) *= 2; + sink_input_list = (sink_input_info**) realloc(sink_input_list, (*max) * sizeof(sink_input_info*)); + + for (int i = counter; i < (*max); ++i) + sink_input_list[i] = NULL; } void sink_input_list_clear(sink_input_info** sink_input_list, int *max) { @@ -38,9 +54,17 @@ void sink_input_list_clear(sink_input_info** sink_input_list, int *max) { (*max) = 0; free(sink_input_list); + sink_input_list = NULL; +} + +void sink_input_check(sink_input_info** sink_input) { + + if ((*sink_input) == NULL) + (*sink_input) = (sink_input_info*) calloc(1, sizeof(sink_input_info)); } int cmp_sink_input_list(const void *a, const void *b) { + sink_input_info* sinka = *((sink_input_info**) a); sink_input_info* sinkb = *((sink_input_info**) b); |