X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=audiod.c;h=0e8e5981085b7d05b8a2a08f35a9bb7944a4d72d;hb=501b83a39828c9d3db5498c7352a2e5b60175bba;hp=a084558b167af829d2c0f6a0fbd71a2610c1f3b0;hpb=cdbc8067a2e27ee7f9e0d8ff11cf415603fc0558;p=paraslash.git diff --git a/audiod.c b/audiod.c index a084558b..0e8e5981 100644 --- a/audiod.c +++ b/audiod.c @@ -44,8 +44,6 @@ static struct lls_parse_result *lpr; #define OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name))) #define OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name))) #define OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name))) -#define ENUM_STRING_VAL(_name) (lls_enum_string_val(OPT_UINT32_VAL(_name), \ - lls_opt(LSG_AUDIOD_PARA_AUDIOD_OPT_ ## _name, CMD_PTR))) __printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log; /** define the array containing all supported audio formats */ @@ -389,11 +387,11 @@ static void parse_config_or_die(void) para_strerror(-ret)); exit(EXIT_FAILURE); } - daemon_set_loglevel(ENUM_STRING_VAL(LOGLEVEL)); + daemon_set_loglevel(OPT_UINT32_VAL(LOGLEVEL)); n = OPT_GIVEN(USER_ALLOW); if (n == 0) return; - uid_whitelist = para_malloc(n * sizeof(uid_t)); + uid_whitelist = arr_alloc(n, sizeof(uid_t)); for (i = 0; i < n; i++) { const char *arg = lls_string_val(i, OPT_RESULT(USER_ALLOW)); int32_t val; @@ -564,7 +562,7 @@ static void open_filters(struct slot_info *s) return; PARA_INFO_LOG("opening %s filters\n", audio_formats[s->format]); assert(s->fns == NULL); - s->fns = para_calloc(nf * sizeof(struct filter_node)); + s->fns = zalloc(nf * sizeof(struct filter_node)); parent = s->receiver_node->btrn; for (i = 0; i < nf; i++) { char buf[20]; @@ -602,7 +600,7 @@ static void open_writers(struct slot_info *s) struct btr_node *parent = s->fns[a->num_filters - 1].btrn; assert(s->wns == NULL); - s->wns = para_calloc(PARA_MAX(1U, a->num_writers) + s->wns = zalloc(PARA_MAX(1U, a->num_writers) * sizeof(struct writer_node)); for (i = 0; i < a->num_writers; i++) { wn = s->wns + i; @@ -629,7 +627,7 @@ static int open_receiver(int format) if (ret < 0) return ret; slot_num = ret; - rn = para_calloc(sizeof(*rn)); + rn = zalloc(sizeof(*rn)); rn->receiver = r; rn->lpr = a->receiver_lpr; rn->btrn = btr_new_node(&(struct btr_node_description) @@ -819,7 +817,7 @@ static int parse_stream_command(const char *txt, const char **cmd) return -E_MISSING_COLON; *cmd = p + 1; len = p - txt; - re = para_malloc(len + 1); + re = alloc(len + 1); strncpy(re, txt, len); re[len] = '\0'; ret = get_matching_audio_format_nums(re); @@ -835,12 +833,9 @@ static int add_filter(int format, const char *cmdline) struct lls_parse_result *flpr; filter_num = filter_setup(cmdline, &cfg, &flpr); - a->filter_lpr = para_realloc(a->filter_lpr, - (nf + 1) * sizeof(flpr)); - a->filter_conf = para_realloc(a->filter_conf, - (nf + 1) * sizeof(void *)); - a->filter_nums = para_realloc(a->filter_nums, - (nf + 1) * sizeof(unsigned)); + a->filter_lpr = arr_realloc(a->filter_lpr, nf + 1, sizeof(flpr)); + a->filter_conf = arr_realloc(a->filter_conf, nf + 1, sizeof(void *)); + a->filter_nums = arr_realloc(a->filter_nums, nf + 1, sizeof(unsigned)); a->filter_nums[nf] = filter_num; a->filter_conf[nf] = cfg; @@ -886,8 +881,8 @@ static int parse_writer_args(void) if (a->num_writers > 0) continue; /* already set up */ a->num_writers = 1; - a->wids = para_malloc(sizeof(int)); - a->writer_lpr = para_malloc(sizeof(struct lls_parse_result *)); + a->wids = alloc(sizeof(int)); + a->writer_lpr = alloc(sizeof(struct lls_parse_result *)); a->wids[0] = check_writer_arg_or_die(NULL, a->writer_lpr); PARA_INFO_LOG("%s writer: %s (default)\n", audio_formats[i], writer_name(a->wids[0])); @@ -1462,7 +1457,7 @@ int main(int argc, char *argv[]) ret = lls(lls_parse(argc, argv, CMD_PTR, &lpr, &errctx)); if (ret < 0) goto out; - daemon_set_loglevel(ENUM_STRING_VAL(LOGLEVEL)); + daemon_set_loglevel(OPT_UINT32_VAL(LOGLEVEL)); daemon_drop_privileges_or_die(OPT_STRING_VAL(USER), OPT_STRING_VAL(GROUP)); version_handle_flag("audiod", OPT_GIVEN(VERSION));