From 610cb53b94af8e95326cd44b7845f35cffdb6bf3 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 26 Oct 2021 20:22:49 +0200 Subject: [PATCH] string: Rename para_malloc() -> alloc(). Just because it's shorter and matches the naming of the new allocators we are about to introduce. The bulk of this patch was created with sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y --- aac_afh.c | 4 ++-- aacdec_filter.c | 2 +- acl.c | 2 +- afh_recv.c | 2 +- afs.c | 2 +- aft.c | 12 ++++++------ amp_filter.c | 2 +- ao_write.c | 2 +- audioc.c | 4 ++-- audiod.c | 8 ++++---- base64.c | 2 +- blob.c | 2 +- buffer_tree.c | 10 +++++----- chunk_queue.c | 4 ++-- client.c | 2 +- client_common.c | 5 ++--- close_on_fork.c | 2 +- command.c | 6 +++--- compress_filter.c | 2 +- crypt_common.c | 2 +- dccp_recv.c | 2 +- fd.c | 2 +- fec.c | 18 +++++++++--------- fecdec_filter.c | 4 ++-- filter.c | 2 +- flacdec_filter.c | 2 +- gcrypt.c | 6 +++--- gui.c | 2 +- http_send.c | 2 +- imdct.c | 6 +++--- interactive.c | 6 +++--- mp.c | 2 +- mp3_afh.c | 4 ++-- mp3dec_filter.c | 2 +- net.c | 6 +++--- ogg_afh_common.c | 2 +- oggdec_filter.c | 4 ++-- openssl.c | 8 ++++---- opus_afh.c | 2 +- opusdec_filter.c | 4 ++-- oss_mix.c | 2 +- play.c | 8 ++++---- recv_common.c | 2 +- resample_filter.c | 6 +++--- sched.c | 2 +- score.c | 4 ++-- send_common.c | 8 ++++---- server.c | 4 ++-- sideband.c | 2 +- spx_afh.c | 2 +- spxdec_filter.c | 2 +- string.c | 24 ++++++++++++------------ string.h | 2 +- sync_filter.c | 6 +++--- user_list.c | 2 +- vss.c | 6 +++--- wav_filter.c | 4 ++-- wma_afh.c | 10 +++++----- wmadec_filter.c | 6 +++--- write_common.c | 2 +- yy/mp.y | 6 +++--- 61 files changed, 136 insertions(+), 137 deletions(-) diff --git a/aac_afh.c b/aac_afh.c index 5c1225b6..c4081f05 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -78,7 +78,7 @@ static int32_t aac_afh_get_track(mp4ff_t *mp4ff, mp4AudioSpecificConfig *masc) static int aac_afh_open(const void *map, size_t mapsize, void **afh_context) { int ret; - struct aac_afh_context *c = para_malloc(sizeof(*c)); + struct aac_afh_context *c = alloc(sizeof(*c)); c->map = map; c->mapsize = mapsize; @@ -282,7 +282,7 @@ static int aac_afh_rewrite_tags(const char *map, size_t mapsize, metadata.count = rv; PARA_NOTICE_LOG("%d metadata item(s) found\n", rv); - metadata.tags = para_malloc((metadata.count + 5) * sizeof(mp4ff_tag_t)); + metadata.tags = alloc((metadata.count + 5) * sizeof(mp4ff_tag_t)); for (i = 0; i < metadata.count; i++) { mp4ff_tag_t *tag = metadata.tags + i; diff --git a/aacdec_filter.c b/aacdec_filter.c index a2459d82..694e399a 100644 --- a/aacdec_filter.c +++ b/aacdec_filter.c @@ -136,7 +136,7 @@ next_buffer: consumed += frame_info.bytesconsumed; if (!frame_info.samples) goto success; - btrbuf = para_malloc(2 * frame_info.samples); + btrbuf = alloc(2 * frame_info.samples); for (i = 0; i < frame_info.samples; i++) { short sh = ((short *)outbuf)[i]; write_int16_host_endian(btrbuf + loaded, sh); diff --git a/acl.c b/acl.c index 59ffab3e..ddf93ecc 100644 --- a/acl.c +++ b/acl.c @@ -81,7 +81,7 @@ no_match: */ void acl_add_entry(struct list_head *acl, char *addr, int netmask) { - struct access_info *ai = para_malloc(sizeof(struct access_info)); + struct access_info *ai = alloc(sizeof(struct access_info)); inet_pton(AF_INET, addr, &ai->addr); ai->netmask = netmask; diff --git a/afh_recv.c b/afh_recv.c index 6a0ec239..e7f85a1b 100644 --- a/afh_recv.c +++ b/afh_recv.c @@ -188,7 +188,7 @@ static int afh_recv_post_select(__a_unused struct sched *s, void *context) pard->map_size, &header, &size); if (size > 0) { PARA_INFO_LOG("writing header (%zu bytes)\n", size); - buf = para_malloc(size); + buf = alloc(size); memcpy(buf, header, size); btr_add_output(buf, size, btrn); afh_free_header(header, pard->audio_format_num); diff --git a/afs.c b/afs.c index 71067025..00a82b02 100644 --- a/afs.c +++ b/afs.c @@ -959,7 +959,7 @@ static int command_post_select(struct sched *s, void *context) close(fd); return 0; } - client = para_malloc(sizeof(*client)); + client = alloc(sizeof(*client)); client->fd = fd; client->connect_time = *now; para_list_add(&client->node, &afs_client_list); diff --git a/aft.c b/aft.c index e0bde7fc..215e8bf2 100644 --- a/aft.c +++ b/aft.c @@ -412,7 +412,7 @@ static void load_chunk_table(struct afh_info *afhi, const struct osl_object *ct) return; } sz = PARA_MIN(((size_t)afhi->chunks_total + 1) * 4, ct->size) + 1; - afhi->chunk_table = para_malloc(sz); + afhi->chunk_table = alloc(sz); for (i = 0; i <= afhi->chunks_total && i * 4 + 3 < ct->size; i++) afhi->chunk_table[i] = read_u32(ct->data + 4 * i); } @@ -1066,7 +1066,7 @@ again: if (ret < 0) return ret; if (!d->hash) - d->hash = para_malloc(HASH_SIZE); + d->hash = alloc(HASH_SIZE); memcpy(d->hash, tmp_hash, HASH_SIZE); free(d->path); ret = get_audio_file_path_of_row(current_aft_row, &d->path); @@ -1224,7 +1224,7 @@ static int sort_matching_paths(struct ls_options *options) int (*compar)(const void *, const void *); int i; - options->data_ptr = para_malloc(nmemb * sizeof(*options->data_ptr)); + options->data_ptr = alloc(nmemb * sizeof(*options->data_ptr)); for (i = 0; i < nmemb; i++) options->data_ptr[i] = options->data + i; @@ -1424,7 +1424,7 @@ static int com_ls(struct command_context *cc, struct lls_parse_result *lpr) ret = lls_serialize_parse_result(lpr, cmd, NULL, &query.size); assert(ret >= 0); query.size += sizeof(*opts); - query.data = para_malloc(query.size); + query.data = alloc(query.size); opts = query.data; memset(opts, 0, sizeof(*opts)); slpr = query.data + sizeof(*opts); @@ -1553,7 +1553,7 @@ static void save_add_callback_buffer(unsigned char *hash, const char *path, size_t afhi_size = sizeof_afhi_buf(afhi); size_t size = CAB_PATH_OFFSET + path_len + afhi_size + sizeof_chunk_table(afhi) + slpr_size; - char *buf = para_malloc(size); + char *buf = alloc(size); uint32_t pos; assert(size <= ~(uint32_t)0); @@ -2320,7 +2320,7 @@ static int com_setatt_callback(struct afs_callback_arg *aca) goto out; /* no attribute modifier given */ goto set_atts; } - p = para_malloc(len); + p = alloc(len); memcpy(p, arg, len - 1); p[len - 1] = '\0'; ret = get_attribute_bitnum_by_name(p, &bitnum); diff --git a/amp_filter.c b/amp_filter.c index 61b1653e..54ff0ade 100644 --- a/amp_filter.c +++ b/amp_filter.c @@ -74,7 +74,7 @@ next_buffer: if (inplace) out = in; else - out = para_malloc(len * 2); + out = alloc(len * 2); for (i = 0; i < len; i++) { int x = (in[i] * factor) >> 6; diff --git a/ao_write.c b/ao_write.c index 037b9299..58da91cf 100644 --- a/ao_write.c +++ b/ao_write.c @@ -184,7 +184,7 @@ static int aow_init(struct writer_node *wn, unsigned sample_rate, ao_info *info; const struct lls_opt_result *r; unsigned n; - struct private_aow_data *pawd = para_malloc(sizeof(*pawd)); + struct private_aow_data *pawd = alloc(sizeof(*pawd)); ao_initialize(); aow_show_drivers(); diff --git a/audioc.c b/audioc.c index af670633..0676f44b 100644 --- a/audioc.c +++ b/audioc.c @@ -165,7 +165,7 @@ static int audioc_post_select(struct sched *s, void *context) if (!FD_ISSET(at->fd, &s->rfds)) return 0; bufsize = PARA_MAX(1024U, OPT_UINT32_VAL(BUFSIZE)); - buf = para_malloc(bufsize); + buf = alloc(bufsize); ret = recv_bin_buffer(at->fd, buf, bufsize); PARA_DEBUG_LOG("recv: %d\n", ret); if (ret == 0) @@ -364,7 +364,7 @@ int main(int argc, char *argv[]) if (ret < 0) goto out; bufsize = PARA_MAX(1024U, OPT_UINT32_VAL(BUFSIZE)); - buf = para_malloc(bufsize); + buf = alloc(bufsize); do { size_t n = ret = recv_bin_buffer(fd, buf, bufsize); if (ret <= 0) diff --git a/audiod.c b/audiod.c index 119adbc0..305fcf3f 100644 --- a/audiod.c +++ b/audiod.c @@ -393,7 +393,7 @@ static void parse_config_or_die(void) n = OPT_GIVEN(USER_ALLOW); if (n == 0) return; - uid_whitelist = para_malloc(n * sizeof(uid_t)); + uid_whitelist = 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; @@ -819,7 +819,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); @@ -886,8 +886,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])); diff --git a/base64.c b/base64.c index 122465f8..ac6f65aa 100644 --- a/base64.c +++ b/base64.c @@ -79,7 +79,7 @@ int base64_decode(char const *src, size_t encoded_size, char **result, if (encoded_size == (size_t)-1) encoded_size = strlen(src); - target = para_malloc(BASE64_MAX_DECODED_SIZE(encoded_size) + 1); + target = alloc(BASE64_MAX_DECODED_SIZE(encoded_size) + 1); for ( i = 0, j = 0, state = 0; diff --git a/blob.c b/blob.c index 4ecbc45b..b6372401 100644 --- a/blob.c +++ b/blob.c @@ -403,7 +403,7 @@ static int stdin_command(struct command_context *cc, if (ret < 0) return ret; query.size = len + 1 + stdin_obj.size; - query.data = para_malloc(query.size); + query.data = alloc(query.size); memcpy(query.data, lls_input(0, lpr), len + 1); if (stdin_obj.size > 0) memcpy((char *)query.data + len + 1, stdin_obj.data, diff --git a/buffer_tree.c b/buffer_tree.c index f0d2002d..b80e707a 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -72,8 +72,8 @@ struct btr_pool *btr_pool_new(const char *name, size_t area_size) struct btr_pool *btrp; PARA_INFO_LOG("%s, %zu bytes\n", name, area_size); - btrp = para_malloc(sizeof(*btrp)); - btrp->area_start = para_malloc(area_size); + btrp = alloc(sizeof(*btrp)); + btrp->area_start = alloc(area_size); btrp->area_end = btrp->area_start + area_size; btrp->rhead = btrp->area_start; btrp->whead = btrp->area_start; @@ -262,7 +262,7 @@ static void btr_pool_deallocate(struct btr_pool *btrp, size_t size) */ struct btr_node *btr_new_node(struct btr_node_description *bnd) { - struct btr_node *btrn = para_malloc(sizeof(*btrn)); + struct btr_node *btrn = alloc(sizeof(*btrn)); btrn->name = para_strdup(bnd->name); btrn->parent = bnd->parent; @@ -1007,7 +1007,7 @@ next: if (!wbr) { /* Make a new wrap buffer combining buf1 and buf2. */ sz = sz1 + sz2; - buf = para_malloc(sz); + buf = alloc(sz); PARA_DEBUG_LOG("merging input buffers: (%p:%zu, %p:%zu) -> %p:%zu\n", buf1, sz1, buf2, sz2, buf, sz); memcpy(buf, buf1, sz1); @@ -1067,7 +1067,7 @@ static int merge_input(struct btr_node *btrn) assert(i == 2); /* make a new btrb that combines the two buffers and a br to it. */ sz = szs[0] + szs[1]; - buf = para_malloc(sz); + buf = alloc(sz); PARA_DEBUG_LOG("%s: memory merging input buffers: (%zu, %zu) -> %zu\n", btrn->name, szs[0], szs[1], sz); memcpy(buf, bufs[0], szs[0]); diff --git a/chunk_queue.c b/chunk_queue.c index cf74cc33..1f11359f 100644 --- a/chunk_queue.c +++ b/chunk_queue.c @@ -52,7 +52,7 @@ int cq_enqueue(struct chunk_queue *cq, const char *buf, size_t num_bytes) if (cq->num_pending + num_bytes > cq->max_pending) return -E_QUEUE; - qc = para_malloc(sizeof(struct queued_chunk)); + qc = alloc(sizeof(struct queued_chunk)); cq->num_pending += num_bytes; qc->buf = buf; qc->num_bytes = num_bytes; @@ -130,7 +130,7 @@ int cq_get(struct queued_chunk *qc, const char **buf, size_t *num_bytes) */ struct chunk_queue *cq_new(size_t max_pending) { - struct chunk_queue *cq = para_malloc(sizeof(*cq)); + struct chunk_queue *cq = alloc(sizeof(*cq)); init_list_head(&cq->q); cq->max_pending = max_pending; cq->num_pending = 0; diff --git a/client.c b/client.c index 8caf4483..20c9971a 100644 --- a/client.c +++ b/client.c @@ -435,7 +435,7 @@ static void select_completer(struct i9e_completion_info *ci, goto free_moods; num_pl = ret; n = num_moods + num_pl; - mops = para_malloc((n + 1) * sizeof(char *)); + mops = alloc((n + 1) * sizeof(char *)); for (i = 0; i < num_moods; i++) mops[i] = make_message("m/%s", moods[i]); for (i = 0; i < num_pl; i++) diff --git a/client_common.c b/client_common.c index f8ee80c9..68c3747b 100644 --- a/client_common.c +++ b/client_common.c @@ -248,7 +248,7 @@ static int send_sb_command(struct client_task *ct) for (i = 0; i < num_inputs; i++) len += strlen(lls_input(i, ct->lpr)) + 1; - p = command = para_malloc(len); + p = command = alloc(len); for (i = 0; i < num_inputs; i++) { const char *str = lls_input(i, ct->lpr); strcpy(p, str); @@ -339,8 +339,7 @@ static int client_post_select(struct sched *s, void *context) free(sbb.iov.iov_base); if (ret < 0) goto out; - ct->challenge_hash = para_malloc(HASH2_SIZE); - + ct->challenge_hash = alloc(HASH2_SIZE); if (has_feature("sha256", ct)) { hash2_function((char *)crypt_buf, APC_CHALLENGE_SIZE, ct->challenge_hash); hash2_to_asc(ct->challenge_hash, buf); diff --git a/close_on_fork.c b/close_on_fork.c index 7b464d09..809f027e 100644 --- a/close_on_fork.c +++ b/close_on_fork.c @@ -31,7 +31,7 @@ struct close_on_fork { */ void add_close_on_fork_list(int fd) { - struct close_on_fork *cof = para_malloc(sizeof(struct close_on_fork)); + struct close_on_fork *cof = alloc(sizeof(struct close_on_fork)); if (!initialized) { init_list_head(&close_on_fork_list); diff --git a/command.c b/command.c index e3f12931..d38f387d 100644 --- a/command.c +++ b/command.c @@ -79,7 +79,7 @@ static char *vss_status_tohuman(unsigned int flags) */ static char *vss_get_status_flags(unsigned int flags) { - char *msg = para_malloc(5 * sizeof(char)); + char *msg = alloc(5 * sizeof(char)); msg[0] = (flags & VSS_PLAYING)? 'P' : '_'; msg[1] = (flags & VSS_NOMORE)? 'O' : '_'; @@ -834,7 +834,7 @@ static int run_command(struct command_context *cc, struct iovec *iov) for (i = 0; p < end; i++) p += strlen(p) + 1; argc = i; - argv = para_malloc((argc + 1) * sizeof(char *)); + argv = alloc((argc + 1) * sizeof(char *)); for (i = 0, p = iov->iov_base; p < end; i++) { argv[i] = para_strdup(p); p += strlen(p) + 1; @@ -889,7 +889,7 @@ int handle_connect(int fd) int ret; unsigned char rand_buf[APC_CHALLENGE_SIZE + 2 * SESSION_KEY_LEN]; unsigned char challenge_hash[HASH2_SIZE]; - char *command = NULL, *buf = para_malloc(HANDSHAKE_BUFSIZE) /* must be on the heap */; + char *command = NULL, *buf = alloc(HANDSHAKE_BUFSIZE) /* must be on the heap */; size_t numbytes; struct command_context cc_struct = {.u = NULL}, *cc = &cc_struct; struct iovec iov; diff --git a/compress_filter.c b/compress_filter.c index ff4ce6fb..7bd30271 100644 --- a/compress_filter.c +++ b/compress_filter.c @@ -66,7 +66,7 @@ next_buffer: if (inplace) op = ip; else - op = para_malloc(length); + op = alloc(length); for (i = 0; i < length / 2; i++) { /* be careful in that heat, my dear */ int sample = *ip++; diff --git a/crypt_common.c b/crypt_common.c index 3a44dbdd..d7471235 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -317,7 +317,7 @@ int decode_private_key(const char *key_file, unsigned char **result, goto unmap; key_size = footer - begin; - key = para_malloc(key_size + 1); + key = alloc(key_size + 1); for (i = 0, j = 0; begin + i < footer; i++) { if (para_isspace(begin[i])) continue; diff --git a/dccp_recv.c b/dccp_recv.c index 639c93fc..d3a18e90 100644 --- a/dccp_recv.c +++ b/dccp_recv.c @@ -76,7 +76,7 @@ static int dccp_recv_open(struct receiver_node *rn) /* Copy CCID preference list (u8 array required) */ given = lls_opt_given(r_c); if (given) { - ccids = para_malloc(given); + ccids = alloc(given); fo = flowopt_new(); for (i = 0; i < given; i++) ccids[i] = lls_int32_val(i, r_c); diff --git a/fd.c b/fd.c index 33891d2e..f7a2802a 100644 --- a/fd.c +++ b/fd.c @@ -286,7 +286,7 @@ int read_nonblock(int fd, void *buf, size_t sz, fd_set *rfds, size_t *num_bytes) int read_pattern(int fd, const char *pattern, size_t bufsize, fd_set *rfds) { size_t n, len; - char *buf = para_malloc(bufsize + 1); + char *buf = alloc(bufsize + 1); int ret = read_nonblock(fd, buf, bufsize, rfds, &n); buf[n] = '\0'; diff --git a/fec.c b/fec.c index 2301cc8d..056b923e 100644 --- a/fec.c +++ b/fec.c @@ -97,7 +97,7 @@ static void init_mul_table(void) static unsigned char *alloc_matrix(int rows, int cols) { - return para_malloc(rows * cols); + return alloc(rows * cols); } /* @@ -245,9 +245,9 @@ static void matmul(unsigned char *a, unsigned char *b, unsigned char *c, static int invert_mat(unsigned char *src, int k) { int irow, icol, row, col, ix, error; - int *indxc = para_malloc(k * sizeof(int)); - int *indxr = para_malloc(k * sizeof(int)); - int *ipiv = para_malloc(k * sizeof(int)); /* elements used as pivots */ + int *indxc = alloc(k * sizeof(int)); + int *indxr = alloc(k * sizeof(int)); + int *ipiv = alloc(k * sizeof(int)); /* elements used as pivots */ unsigned char c, *p, *id_row = alloc_matrix(1, k), *temp_row = alloc_matrix(1, k); @@ -371,9 +371,9 @@ static void invert_vdm(unsigned char *src, int k) * c holds the coefficient of P(x) = Prod (x - p_i), i=0..k-1 * b holds the coefficient for the matrix inversion */ - c = para_malloc(k); - b = para_malloc(k); - p = para_malloc(k); + c = alloc(k); + b = alloc(k); + p = alloc(k); for (j = 1, i = 0; i < k; i++, j += k) { c[i] = 0; @@ -466,7 +466,7 @@ int fec_new(int k, int n, struct fec_parms **result) if (k < 1 || k > GF_SIZE + 1 || n > GF_SIZE + 1 || k > n) return -E_FEC_PARMS; - parms = para_malloc(sizeof(struct fec_parms)); + parms = alloc(sizeof(struct fec_parms)); parms->k = k; parms->n = n; parms->enc_matrix = alloc_matrix(n, k); @@ -607,7 +607,7 @@ int fec_decode(struct fec_parms *parms, unsigned char **data, int *idx, if (ret < 0) return ret; /* do the actual decoding */ - slice = para_malloc(k * sizeof(unsigned char *)); + slice = alloc(k * sizeof(unsigned char *)); for (row = 0; row < k; row++) { if (idx[row] >= k) { slice[row] = para_calloc(sz); diff --git a/fecdec_filter.c b/fecdec_filter.c index 13d4f7b2..d7162adc 100644 --- a/fecdec_filter.c +++ b/fecdec_filter.c @@ -225,7 +225,7 @@ static int add_slice(char *buf, struct fecdec_group *fg) } if (fg->num_slices == 0) { fg->num_slices = fg->h.slices_per_group; - fg->idx = para_malloc(fg->num_slices * sizeof(int)); + fg->idx = alloc(fg->num_slices * sizeof(int)); fg->data = para_calloc(fg->num_slices * sizeof(unsigned char *)); } r = fg->num_received_slices; @@ -236,7 +236,7 @@ static int add_slice(char *buf, struct fecdec_group *fg) return 0; } fg->idx[r] = slice_num; - fg->data[r] = para_malloc(fg->h.slice_bytes); + fg->data[r] = alloc(fg->h.slice_bytes); memcpy(fg->data[r], buf, fg->h.slice_bytes); fg->num_received_slices++; return 1; diff --git a/filter.c b/filter.c index d4a24239..05d1d4d3 100644 --- a/filter.c +++ b/filter.c @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) EMBRACE(.name = "stdin")); stdin_task_register(sit, &s); - fns = para_malloc(OPT_GIVEN(FILTER) * sizeof(*fns)); + fns = alloc(OPT_GIVEN(FILTER) * sizeof(*fns)); for (i = 0, parent = sit->btrn; i < OPT_GIVEN(FILTER); i++) { const char *fa = lls_string_val(i, OPT_RESULT(FILTER)); const char *name; diff --git a/flacdec_filter.c b/flacdec_filter.c index 6a3a8eff..f859c840 100644 --- a/flacdec_filter.c +++ b/flacdec_filter.c @@ -135,7 +135,7 @@ static FLAC__StreamDecoderWriteStatus write_cb( struct btr_node *btrn = fn->btrn; size_t k, n = frame->header.blocksize; unsigned channels = FLAC__stream_decoder_get_channels(decoder); - char *outbuffer = para_malloc(n * channels * 2); + char *outbuffer = alloc(n * channels * 2); if (channels == 1) { for (k = 0; k < n; k++) { diff --git a/gcrypt.c b/gcrypt.c index 506f0bb8..763fa6de 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -406,7 +406,7 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result) ret = -E_SEXP_BUILD; goto free_params; } - key = para_malloc(sizeof(*key)); + key = alloc(sizeof(*key)); key->sexp = sexp; *result = key; ret = bits; @@ -456,7 +456,7 @@ int apc_get_pubkey(const char *key_file, struct asymmetric_key **result) goto release_n; } PARA_INFO_LOG("successfully read %u bit ssh public key\n", bits); - key = para_malloc(sizeof(*key)); + key = alloc(sizeof(*key)); key->num_bytes = ret; key->sexp = sexp; *result = key; @@ -624,7 +624,7 @@ struct stream_cipher { struct stream_cipher *sc_new(const unsigned char *data, int len) { gcry_error_t gret; - struct stream_cipher *sc = para_malloc(sizeof(*sc)); + struct stream_cipher *sc = alloc(sizeof(*sc)); assert(len >= 2 * AES_CRT128_BLOCK_SIZE); gret = gcry_cipher_open(&sc->handle, GCRY_CIPHER_AES128, diff --git a/gui.c b/gui.c index d779ff86..06aada3c 100644 --- a/gui.c +++ b/gui.c @@ -431,7 +431,7 @@ static void rb_add_entry(int color, char *msg) if (strwidth(msg, &len) < 0) return; - new = para_malloc(sizeof(struct rb_entry)); + new = alloc(sizeof(struct rb_entry)); new->color = color; new->len = len; new->msg = msg; diff --git a/http_send.c b/http_send.c index c6b9decc..fab703cd 100644 --- a/http_send.c +++ b/http_send.c @@ -191,7 +191,7 @@ static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds) sc = accept_sender_client(hss, rfds); if (!sc) return; - phsd = para_malloc(sizeof(*phsd)); + phsd = alloc(sizeof(*phsd)); sc->private_data = phsd; phsd->status = HTTP_CONNECTED; } diff --git a/imdct.c b/imdct.c index 93577b54..518d4782 100644 --- a/imdct.c +++ b/imdct.c @@ -336,7 +336,7 @@ static int fft_init(struct fft_context *s, int nbits) s->nbits = nbits; n = 1 << nbits; - s->revtab = para_malloc(n * sizeof(uint16_t)); + s->revtab = alloc(n * sizeof(uint16_t)); for (j = 4; j <= nbits; j++) { int k = 1 << j; double freq = 2 * M_PI / k; @@ -371,8 +371,8 @@ int imdct_init(int nbits, struct mdct_context **result) s->nbits = nbits; s->n = n; n4 = n >> 2; - s->tcos = para_malloc(n4 * sizeof(fftsample_t)); - s->tsin = para_malloc(n4 * sizeof(fftsample_t)); + s->tcos = alloc(n4 * sizeof(fftsample_t)); + s->tsin = alloc(n4 * sizeof(fftsample_t)); for (i = 0; i < n4; i++) { alpha = 2 * M_PI * (i + 1.0 / 8.0) / n; diff --git a/interactive.c b/interactive.c index 8c4545b4..ee4878fb 100644 --- a/interactive.c +++ b/interactive.c @@ -645,7 +645,7 @@ int i9e_select(int n, fd_set *readfds, fd_set *writefds, int i9e_extract_completions(const char *word, char **string_list, char ***result) { - char **matches = para_malloc(sizeof(char *)); + char **matches = alloc(sizeof(char *)); int match_count = 0, matches_len = 1; char **p; int len = strlen(word); @@ -693,7 +693,7 @@ char **i9e_complete_commands(const char *word, struct i9e_completer *completers) if (is_prefix(word, cmd, len)) match_count++; } - matches = para_malloc((match_count + 1) * sizeof(*matches)); + matches = alloc((match_count + 1) * sizeof(*matches)); for (i = 0, match_count = 0; (cmd = completers[i].name); i++) if (is_prefix(word, cmd, len)) matches[match_count++] = para_strdup(cmd); @@ -777,7 +777,7 @@ int i9e_print_completions(struct i9e_completer *completers) if (*p == ' ') p++; n = end - p + 1; - ci.word = para_malloc(n + 1); + ci.word = alloc(n + 1); strncpy(ci.word, p, n); ci.word[n] = '\0'; create_matches: diff --git a/mp.c b/mp.c index c537e729..f85ded85 100644 --- a/mp.c +++ b/mp.c @@ -90,7 +90,7 @@ unsigned parse_quoted_string(const char *src, const char quote_chars[2], assert(len >= 2); assert(src[0] == quote_chars[0]); - p = dst = para_malloc(len - 1); + p = dst = alloc(len - 1); backslash = false; for (n = 1;; n++) { char c; diff --git a/mp3_afh.c b/mp3_afh.c index 728b25b8..1e105b7e 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -348,7 +348,7 @@ static int mp3_rewrite_tags(const char *map, size_t mapsize, if (ret < 0) goto out; new_v2size = id3_tag_render(v2_tag, NULL); - v2_buffer = para_malloc(new_v2size); + v2_buffer = alloc(new_v2size); id3_tag_render(v2_tag, v2_buffer); PARA_INFO_LOG("writing v2 tag (%lu bytes)\n", new_v2size); ret = write_all(fd, (char *)v2_buffer, new_v2size); @@ -598,7 +598,7 @@ static int mp3_read_info(unsigned char *map, size_t numbytes, int fd, const char *tag_versions[] = {"no", "id3v1", "id3v2", "id3v1+id3v2"}; afhi->chunks_total = 0; - afhi->chunk_table = para_malloc(chunk_table_size * sizeof(uint32_t)); + afhi->chunk_table = alloc(chunk_table_size * sizeof(uint32_t)); while (1) { int freq, br; struct timeval tmp, cct; /* current chunk time */ diff --git a/mp3dec_filter.c b/mp3dec_filter.c index ccb1553b..69112c76 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -144,7 +144,7 @@ decode: } fn->min_iqs = 0; mad_synth_frame(&pmd->synth, &pmd->frame); - outbuffer = para_malloc(pmd->synth.pcm.length * 2 * pmd->channels); + outbuffer = alloc(pmd->synth.pcm.length * 2 * pmd->channels); loaded = 0; for (i = 0; i < pmd->synth.pcm.length; i++) { int sample = MAD_TO_SHORT(pmd->synth.pcm.samples[0][i]); diff --git a/net.c b/net.c index e1951e5e..474808ff 100644 --- a/net.c +++ b/net.c @@ -286,7 +286,7 @@ struct flowopts { */ struct flowopts *flowopt_new(void) { - struct flowopts *new = para_malloc(sizeof(*new)); + struct flowopts *new = alloc(sizeof(*new)); init_list_head(&new->sockopts); return new; @@ -307,7 +307,7 @@ struct flowopts *flowopt_new(void) void flowopt_add(struct flowopts *fo, int lev, int opt, const char *name, const void *val, int len) { - struct pre_conn_opt *new = para_malloc(sizeof(*new)); + struct pre_conn_opt *new = alloc(sizeof(*new)); new->sock_option = opt; new->sock_level = lev; @@ -317,7 +317,7 @@ void flowopt_add(struct flowopts *fo, int lev, int opt, new->opt_val = NULL; new->opt_len = 0; } else { - new->opt_val = para_malloc(len); + new->opt_val = alloc(len); new->opt_len = len; memcpy(new->opt_val, val, len); } diff --git a/ogg_afh_common.c b/ogg_afh_common.c index 3e36bdd5..155a1899 100644 --- a/ogg_afh_common.c +++ b/ogg_afh_common.c @@ -167,7 +167,7 @@ int oac_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, PARA_INFO_LOG("%" PRIu32 " seconds, %d frames/chunk\n", afhi->seconds_total, frames_per_chunk); ct_size = 250; - afhi->chunk_table = para_malloc(ct_size * sizeof(uint32_t)); + afhi->chunk_table = alloc(ct_size * sizeof(uint32_t)); afhi->chunk_table[0] = 0; afhi->chunk_table[1] = afhi->header_len; oss.returned = afhi->header_len; diff --git a/oggdec_filter.c b/oggdec_filter.c index 708a27e5..143648c8 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -121,7 +121,7 @@ static int ogg_init(struct filter_node *fn) struct btr_node *btrn = fn->btrn; int ret, oret; size_t iqs; - struct OggVorbis_File *vf = para_malloc(sizeof(*vf)); + struct OggVorbis_File *vf = alloc(sizeof(*vf)); PARA_NOTICE_LOG("iqs: %zu, min_iqs: %zu, opening ov callbacks\n", btr_get_input_queue_size(btrn), fn->min_iqs); @@ -228,7 +228,7 @@ static int ogg_post_select(__a_unused struct sched *s, void *context) goto out; } have = 0; - buf = para_malloc(OGGDEC_OUTPUT_CHUNK_SIZE); + buf = alloc(OGGDEC_OUTPUT_CHUNK_SIZE); for (;;) { ret = ov_read(pod->vf, buf + have, OGGDEC_OUTPUT_CHUNK_SIZE - have, ENDIAN, 2 /* 16 bit */, 1 /* signed */, NULL); diff --git a/openssl.c b/openssl.c index 32891cbb..9d3ad577 100644 --- a/openssl.c +++ b/openssl.c @@ -283,7 +283,7 @@ int apc_get_pubkey(const char *key_file, struct asymmetric_key **result) unsigned char *blob; size_t decoded_size; int ret; - struct asymmetric_key *key = para_malloc(sizeof(*key)); + struct asymmetric_key *key = alloc(sizeof(*key)); ret = decode_public_key(key_file, &blob, &decoded_size); if (ret < 0) @@ -324,7 +324,7 @@ int apc_priv_decrypt(const char *key_file, unsigned char *outbuf, return ret; if (inlen < 0) return -E_RSA; - priv = para_malloc(sizeof(*priv)); + priv = alloc(sizeof(*priv)); ret = get_private_key(key_file, &priv->rsa); if (ret < 0) { free(priv); @@ -366,7 +366,7 @@ struct stream_cipher { struct stream_cipher *sc_new(const unsigned char *data, int len) { - struct stream_cipher *sc = para_malloc(sizeof(*sc)); + struct stream_cipher *sc = alloc(sizeof(*sc)); assert(len >= 2 * AES_CRT128_BLOCK_SIZE); sc->aes = EVP_CIPHER_CTX_new(); @@ -390,7 +390,7 @@ static void aes_ctr128_crypt(EVP_CIPHER_CTX *ctx, struct iovec *src, *dst = (typeof(*dst)) { /* Add one for the terminating zero byte. */ - .iov_base = para_malloc(inlen + 1), + .iov_base = alloc(inlen + 1), .iov_len = inlen }; ret = EVP_EncryptUpdate(ctx, dst->iov_base, &outlen, src->iov_base, inlen); diff --git a/opus_afh.c b/opus_afh.c index dca6cfba..0a291bb1 100644 --- a/opus_afh.c +++ b/opus_afh.c @@ -179,7 +179,7 @@ static size_t opus_make_meta_packet(struct taginfo *tags, char **result) } PARA_DEBUG_LOG("meta packet size: %zu bytes\n", sz); /* terminating zero byte for the last sprintf() */ - buf = p = para_malloc(sz + 1); + buf = p = alloc(sz + 1); memcpy(p, OPUS_COMMENT_HEADER, strlen(OPUS_COMMENT_HEADER)); p += strlen(OPUS_COMMENT_HEADER); write_u32(p, comment_sz); diff --git a/opusdec_filter.c b/opusdec_filter.c index 10ed394d..7878b422 100644 --- a/opusdec_filter.c +++ b/opusdec_filter.c @@ -153,7 +153,7 @@ static void opusdec_add_output(short *pcm, int frames_available, if (tmp_skip > 0) { short *in = pcm + ctx->channels * tmp_skip; - short *out = para_malloc(bytes); + short *out = alloc(bytes); memcpy(out, in, bytes); free(pcm); pcm = out; @@ -193,7 +193,7 @@ static int decode_packet(struct opusdec_context *ctx, ogg_packet *op, /* don't care for anything except opus eos */ if (op->e_o_s && ctx->os.serialno == ctx->opus_serialno) ctx->eos = true; - output = para_malloc(sizeof(short) * MAX_FRAME_SIZE * ctx->channels); + output = alloc(sizeof(short) * MAX_FRAME_SIZE * ctx->channels); ret = opus_multistream_decode(ctx->st, (unsigned char *)op->packet, op->bytes, output, MAX_FRAME_SIZE, 0); if (ret < 0) { diff --git a/oss_mix.c b/oss_mix.c index f80301e9..0814336f 100644 --- a/oss_mix.c +++ b/oss_mix.c @@ -56,7 +56,7 @@ static int oss_mix_open(const char *dev, struct mixer_handle **handle) PARA_ERROR_LOG("could not open %s\n", dev); return ret; } - h = para_malloc(sizeof(*h)); + h = alloc(sizeof(*h)); h->fd = ret; *handle = h; return 1; diff --git a/play.c b/play.c index 14fac42f..7c411850 100644 --- a/play.c +++ b/play.c @@ -288,7 +288,7 @@ static int shuffle_compare(__a_unused const void *a, __a_unused const void *b) static void init_shuffle_map(void) { unsigned n, num_inputs = lls_num_inputs(play_lpr); - shuffle_map = para_malloc(num_inputs * sizeof(unsigned)); + shuffle_map = alloc(num_inputs * sizeof(unsigned)); for (n = 0; n < num_inputs; n++) shuffle_map[n] = n; if (!OPT_GIVEN(RANDOMIZE)) @@ -591,7 +591,7 @@ static char *get_user_key_map_seq(int key) if (!p) return NULL; len = p - kma; - result = para_malloc(len + 1); + result = alloc(len + 1); memcpy(result, kma, len); result[len] = '\0'; return result; @@ -611,7 +611,7 @@ static char *get_key_map_seq_safe(int key) if (len == 1 && isprint(*seq)) return seq; - sseq = para_malloc(2 + 2 * len + 1); + sseq = alloc(2 + 2 * len + 1); sseq[0] = '0'; sseq[1] = 'x'; for (n = 0; n < len; n++) { @@ -651,7 +651,7 @@ static char **get_mapped_keyseqs(void) char **result; int i; - result = para_malloc((NUM_MAPPED_KEYS + 1) * sizeof(char *)); + result = alloc((NUM_MAPPED_KEYS + 1) * sizeof(char *)); FOR_EACH_MAPPED_KEY(i) { char *seq = get_key_map_seq(i); result[i] = seq; diff --git a/recv_common.c b/recv_common.c index 31fd81f1..2d3ae2cd 100644 --- a/recv_common.c +++ b/recv_common.c @@ -41,7 +41,7 @@ int check_receiver_arg(const char *ra, struct lls_parse_result **lprp) *lprp = NULL; if (!ra || !*ra) { argc = 1; - argv = para_malloc(2 * sizeof(char*)); + argv = alloc(2 * sizeof(char*)); argv[0] = para_strdup("http"); argv[1] = NULL; } else { diff --git a/resample_filter.c b/resample_filter.c index bbdda51c..acbf1b41 100644 --- a/resample_filter.c +++ b/resample_filter.c @@ -167,10 +167,10 @@ static int resample_frames(int16_t *in, size_t num_frames, bool have_more, data.output_frames = num_frames * ctx->ratio + 1; out_samples = data.output_frames * ctx->channels; - in_float = para_malloc(num_samples * sizeof(float)); + in_float = alloc(num_samples * sizeof(float)); src_short_to_float_array(in, in_float, num_samples); data.data_in = in_float; - data.data_out = para_malloc(out_samples * sizeof(float)); + data.data_out = alloc(out_samples * sizeof(float)); ret = src_process(ctx->src_state, &data); free(in_float); if (ret != 0) { @@ -179,7 +179,7 @@ static int resample_frames(int16_t *in, size_t num_frames, bool have_more, return -E_LIBSAMPLERATE; } out_samples = data.output_frames_gen * ctx->channels; - out = para_malloc(out_samples * sizeof(short)); + out = alloc(out_samples * sizeof(short)); src_float_to_short_array(data.data_out, out, out_samples); free(data.data_out); *result = out; diff --git a/sched.c b/sched.c index aac8efed..b2e78a1b 100644 --- a/sched.c +++ b/sched.c @@ -239,7 +239,7 @@ void sched_shutdown(struct sched *s) */ struct task *task_register(struct task_info *info, struct sched *s) { - struct task *t = para_malloc(sizeof(*t)); + struct task *t = alloc(sizeof(*t)); assert(info->post_select); diff --git a/score.c b/score.c index 894e8ca3..54af56f7 100644 --- a/score.c +++ b/score.c @@ -119,7 +119,7 @@ int score_add(const struct osl_row *aft_row, long score) score_objs[SCORECOL_AFT_ROW].size = size; size = score_table_desc.column_descriptions[SCORECOL_SCORE].data_size; - score_objs[SCORECOL_SCORE].data = para_malloc(size); + score_objs[SCORECOL_SCORE].data = alloc(size); score_objs[SCORECOL_SCORE].size = size; *(long *)(score_objs[SCORECOL_SCORE].data) = score; @@ -176,7 +176,7 @@ int score_update(const struct osl_row *aft_row, long percent) return ret; new_score--; obj.size = sizeof(long); - obj.data = para_malloc(obj.size); + obj.data = alloc(obj.size); *(long *)obj.data = new_score; PARA_DEBUG_LOG("new score: %ld, rank %u/%u\n", new_score, new_pos, n); return osl(osl_update_object(score_table, row, SCORECOL_SCORE, &obj)); diff --git a/send_common.c b/send_common.c index 90242d5c..4574c697 100644 --- a/send_common.c +++ b/send_common.c @@ -120,14 +120,14 @@ void init_sender_status(struct sender_status *ss, if (n == 0) { ss->num_listen_fds = 1; - ss->listen_addresses = para_malloc(sizeof(char *)); + ss->listen_addresses = alloc(sizeof(char *)); ss->listen_addresses[0] = NULL; - ss->listen_fds = para_malloc(sizeof(int)); + ss->listen_fds = alloc(sizeof(int)); ss->listen_fds[0] = -1; } else { ss->num_listen_fds = n; - ss->listen_addresses = para_malloc(n * sizeof(char *)); - ss->listen_fds = para_malloc(n * sizeof(int)); + ss->listen_addresses = alloc(n * sizeof(char *)); + ss->listen_fds = alloc(n * sizeof(int)); FOR_EACH_LISTEN_FD(i, ss) { ss->listen_addresses[i] = para_strdup(lls_string_val(i, listen_address_opt_result)); diff --git a/server.c b/server.c index e0df714b..7ef0fb0b 100644 --- a/server.c +++ b/server.c @@ -432,14 +432,14 @@ static void init_server_command_task(struct server_command_task *sct, sct->argv = argv; if (!OPT_GIVEN(LISTEN_ADDRESS)) { sct->num_listen_fds = 1; - sct->listen_fds = para_malloc(sizeof(int)); + sct->listen_fds = alloc(sizeof(int)); ret = para_listen_simple(IPPROTO_TCP, port); if (ret < 0) goto err; sct->listen_fds[0] = ret; } else { sct->num_listen_fds = OPT_GIVEN(LISTEN_ADDRESS); - sct->listen_fds = para_malloc(sct->num_listen_fds * sizeof(int)); + sct->listen_fds = alloc(sct->num_listen_fds * sizeof(int)); for (n = 0; n < OPT_GIVEN(LISTEN_ADDRESS); n++) { const char *arg; arg = lls_string_val(n, OPT_RESULT(LISTEN_ADDRESS)); diff --git a/sideband.c b/sideband.c index ed7867a1..cd549ddc 100644 --- a/sideband.c +++ b/sideband.c @@ -266,7 +266,7 @@ int sb_received(struct sb_context *c, size_t nbytes, struct sb_buffer *result) */ if (sbb->iov.iov_len == (size_t)-1) return -E_SB_PACKET_SIZE; - sbb->iov.iov_base = para_malloc(sbb->iov.iov_len + 1); + sbb->iov.iov_base = alloc(sbb->iov.iov_len + 1); return 0; /* ready to read body */ success: *result = c->sbb; diff --git a/spx_afh.c b/spx_afh.c index caeacb19..cd3b7cde 100644 --- a/spx_afh.c +++ b/spx_afh.c @@ -195,7 +195,7 @@ static size_t spx_make_meta_packet(struct taginfo *tags, char **result) } PARA_DEBUG_LOG("meta packet size: %zu bytes\n", sz); /* terminating zero byte for the last sprintf() */ - buf = p = para_malloc(sz + 1); + buf = p = alloc(sz + 1); write_u32(p, comment_sz); p += 4; strcpy(p, tags->comment); diff --git a/spxdec_filter.c b/spxdec_filter.c index 7be817dd..1a4fe9a7 100644 --- a/spxdec_filter.c +++ b/spxdec_filter.c @@ -171,7 +171,7 @@ static int speexdec_write_frames(int packet_no, if (new_frame_size <= 0) continue; samples = new_frame_size * psd->shi.channels; - btr_output = para_malloc(2 * samples); + btr_output = alloc(2 * samples); for (i = 0; i < samples; i++) btr_output[i] = read_u16(output + i + skip_idx); btr_add_output((char *)btr_output, samples * 2, btrn); diff --git a/string.c b/string.c index cc6dc2e2..b75d0af3 100644 --- a/string.c +++ b/string.c @@ -55,7 +55,7 @@ __must_check void *para_realloc(void *p, size_t size) * * \sa malloc(3). */ -__must_check __malloc void *para_malloc(size_t size) +__must_check __malloc void *alloc(size_t size) { void *p; @@ -83,7 +83,7 @@ __must_check __malloc void *para_malloc(size_t size) */ __must_check __malloc void *para_calloc(size_t size) { - void *ret = para_malloc(size); + void *ret = alloc(size); memset(ret, 0, size); return ret; @@ -138,7 +138,7 @@ __printf_2_0 unsigned xvasprintf(char **result, const char *fmt, va_list ap) size_t size = 150; va_list aq; - *result = para_malloc(size + 1); + *result = alloc(size + 1); va_copy(aq, ap); ret = vsnprintf(*result, size, fmt, aq); va_end(aq); @@ -340,7 +340,7 @@ int for_each_line(unsigned flags, char *buf, size_t size, if (!(flags & FELF_DISCARD_FIRST) || start != buf) { if (flags & FELF_READ_ONLY) { size_t s = end - start; - char *b = para_malloc(s + 1); + char *b = alloc(s + 1); memcpy(b, start, s); b[s] = '\0'; ret = line_handler(b, private_data); @@ -444,7 +444,7 @@ __printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...) int ret, sz_off = (b->flags & PBF_SIZE_PREFIX)? 5 : 0; if (!b->buf) { - b->buf = para_malloc(128); + b->buf = alloc(128); b->size = 128; b->offset = 0; } @@ -592,7 +592,7 @@ static int get_next_word(const char *buf, const char *delim, char **word) char *out; int ret, state = 0; - out = para_malloc(strlen(buf) + 1); + out = alloc(strlen(buf) + 1); *out = '\0'; *word = out; for (in = buf; *in; in++) { @@ -724,7 +724,7 @@ void free_argv(char **argv) static int create_argv_offset(int offset, const char *buf, const char *delim, char ***result) { - char *word, **argv = para_malloc((offset + 1) * sizeof(char *)); + char *word, **argv = alloc((offset + 1) * sizeof(char *)); const char *p; int i, ret; @@ -832,7 +832,7 @@ int para_regcomp(regex_t *preg, const char *regex, int cflags) if (ret == 0) return 1; size = regerror(ret, preg, NULL, 0); - buf = para_malloc(size); + buf = alloc(size); regerror(ret, preg, buf, size); PARA_ERROR_LOG("%s\n", buf); free(buf); @@ -858,7 +858,7 @@ char *safe_strdup(const char *src, size_t len) char *p; assert(len < (size_t)-1); - p = para_malloc(len + 1); + p = alloc(len + 1); if (len > 0) memcpy(p, src, len); p[len] = '\0'; @@ -1012,7 +1012,7 @@ __must_check int strwidth(const char *s, size_t *result) return -ERRNO_TO_PARA_ERROR(errno); if (num_wchars == 0) return 0; - dest = para_malloc((num_wchars + 1) * sizeof(*dest)); + dest = alloc((num_wchars + 1) * sizeof(*dest)); src = s; memset(&state, 0, sizeof(state)); num_wchars = mbsrtowcs(dest, &src, num_wchars, &state); @@ -1067,7 +1067,7 @@ __must_check int sanitize_str(const char *src, size_t max_width, num_wchars = mbsrtowcs(NULL, &src, 0, &state); if (num_wchars == (size_t)-1) return -ERRNO_TO_PARA_ERROR(errno); - wcs = para_malloc((num_wchars + 1) * sizeof(*wcs)); + wcs = alloc((num_wchars + 1) * sizeof(*wcs)); memset(&state, 0, sizeof(state)); num_wchars = mbsrtowcs(wcs, &src, num_wchars + 1, &state); assert(num_wchars != (size_t)-1); @@ -1078,7 +1078,7 @@ __must_check int sanitize_str(const char *src, size_t max_width, } wcs[n] = L'\0'; n = wcstombs(NULL, wcs, 0) + 1; - *result = para_malloc(n); + *result = alloc(n); num_wchars = wcstombs(*result, wcs, n); assert(num_wchars != (size_t)-1); free(wcs); diff --git a/string.h b/string.h index 08b9965f..02e31577 100644 --- a/string.h +++ b/string.h @@ -68,7 +68,7 @@ int for_each_line(unsigned flags, char *buf, size_t size, ) __must_check void *para_realloc(void *p, size_t size); -__must_check __malloc void *para_malloc(size_t size); +__must_check __malloc void *alloc(size_t size); __must_check __malloc void *para_calloc(size_t size); __must_check __malloc char *para_strdup(const char *s); diff --git a/sync_filter.c b/sync_filter.c index 8e9ff2c5..6fdf8e46 100644 --- a/sync_filter.c +++ b/sync_filter.c @@ -148,7 +148,7 @@ static void sync_open(struct filter_node *fn) close(fd); goto fail; } - buddy = para_malloc(sizeof(*buddy)); + buddy = alloc(sizeof(*buddy)); buddy->fd = fd; buddy->sbi = sbi + i; buddy->ping_received = false; @@ -176,12 +176,12 @@ static void *sync_setup(const struct lls_parse_result *lpr) r_b = FILTER_CMD_OPT_RESULT(SYNC, BUDDY, lpr); n = lls_opt_given(r_b); - sbi = para_malloc(n * sizeof(*sbi)); + sbi = alloc(n * sizeof(*sbi)); PARA_INFO_LOG("initializing buddy info array of length %u\n", n); for (i = 0; i < n; i++) { const char *url = lls_string_val(i, r_b); size_t len = strlen(url); - char *host = para_malloc(len + 1); + char *host = alloc(len + 1); int port; struct addrinfo *ai; diff --git a/user_list.c b/user_list.c index 32a4309d..f2436c9e 100644 --- a/user_list.c +++ b/user_list.c @@ -110,7 +110,7 @@ void user_list_init(const char *user_list_file) apc_free_pubkey(pubkey); continue; } - u = para_malloc(sizeof(*u)); + u = alloc(sizeof(*u)); u->name = para_strdup(n); u->pubkey = pubkey; u->perms = 0; diff --git a/vss.c b/vss.c index f9bf57b5..00dff8a8 100644 --- a/vss.c +++ b/vss.c @@ -335,10 +335,10 @@ static int initialize_fec_client(struct fec_client *fc, struct vss_task *vsst) ret = fec_new(k, n, &fc->parms); if (ret < 0) return ret; - fc->src_data = para_malloc(k * sizeof(char *)); + fc->src_data = alloc(k * sizeof(char *)); for (i = 0; i < k; i++) - fc->src_data[i] = para_malloc(fc->mps); - fc->enc_buf = para_malloc(fc->mps); + fc->src_data[i] = alloc(fc->mps); + fc->enc_buf = alloc(fc->mps); fc->state = FEC_STATE_READY_TO_RUN; fc->next_header_time.tv_sec = 0; diff --git a/wav_filter.c b/wav_filter.c index e749160d..a2636952 100644 --- a/wav_filter.c +++ b/wav_filter.c @@ -53,7 +53,7 @@ static void wav_open(struct filter_node *fn) { int *bof; - fn->private_data = para_malloc(sizeof(int)); + fn->private_data = alloc(sizeof(int)); bof = fn->private_data; *bof = 1; } @@ -101,7 +101,7 @@ static int wav_post_select(__a_unused struct sched *s, void *context) free(buf); if (ret < 0) goto err; - header = para_malloc(WAV_HEADER_LEN); + header = alloc(WAV_HEADER_LEN); make_wav_header(ch, rate, header); btr_add_output(header, WAV_HEADER_LEN, btrn); ret = -E_WAV_SUCCESS; diff --git a/wma_afh.c b/wma_afh.c index 63e49677..f2afae3b 100644 --- a/wma_afh.c +++ b/wma_afh.c @@ -195,7 +195,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, uint32_t packet_size size_t ct_size = 250; int ret, count = 0, num_frames, num_superframes; - afhi->chunk_table = para_malloc(ct_size * sizeof(uint32_t)); + afhi->chunk_table = alloc(ct_size * sizeof(uint32_t)); afhi->chunk_table[0] = 0; afhi->chunk_table[1] = afhi->header_len; @@ -334,7 +334,7 @@ static int convert_utf8_to_utf16(char *src, char **dst) /* even though src is in UTF-8, strlen() should DTRT */ inbytes = inbytesleft = strlen(src); outbytes = outbytesleft = 4 * inbytes + 2; /* hope that's enough */ - *dst = outbuf = para_malloc(outbytes); + *dst = outbuf = alloc(outbytes); sz = iconv(cd, ICONV_CAST &inbuf, &inbytesleft, &outbuf, &outbytesleft); if (sz == (size_t)-1) { ret = -ERRNO_TO_PARA_ERROR(errno); @@ -411,7 +411,7 @@ static int make_cdo(struct taginfo *tags, const struct asf_object *cdo, result->size = 16 + 8 + 5 * 2 + title_bytes + artist_bytes + orig_cr_bytes + comment_bytes + orig_rating_bytes; PARA_DEBUG_LOG("cdo is %zu bytes\n", (size_t)result->size); - p = result->ptr = para_malloc(result->size); + p = result->ptr = alloc(result->size); memcpy(p, content_description_header, 16); p += 16; write_u64(p, result->size); @@ -469,7 +469,7 @@ static int make_ecdo(struct taginfo *tags, struct asf_object *result) result->size += 2 + sizeof(album_tag_header) + 2 + 2 + 2 + album_bytes; result->size += 2 + sizeof(year_tag_header) + 2 + 2 + 2 + year_bytes; - p = result->ptr = para_malloc(result->size); + p = result->ptr = alloc(result->size); memcpy(p, extended_content_header, 16); p += 16; write_u64(p, result->size); @@ -622,7 +622,7 @@ static int wma_rewrite_tags(const char *map, size_t mapsize, if (top.reserved2 != 2) return -E_NO_WMA; p++; /* objects start at p */ - top.objects = para_malloc(top.num_objects * sizeof(struct asf_object)); + top.objects = alloc(top.num_objects * sizeof(struct asf_object)); ret = read_asf_objects(p, top.size - (p - map), top.num_objects, top.objects, &ton); if (ret < 0) diff --git a/wmadec_filter.c b/wmadec_filter.c index edf50cb0..88f69896 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -160,8 +160,8 @@ static void init_coef_vlc(struct private_wmadec_data *pwd, int sidx, int didx) int i, l, j, k, level, n = src->n; init_vlc(dst, VLCBITS, n, src->huffbits, src->huffcodes, 4); - pwd->run_table[didx] = para_malloc(n * sizeof(uint16_t)); - pwd->level_table[didx] = para_malloc(n * sizeof(uint16_t)); + pwd->run_table[didx] = alloc(n * sizeof(uint16_t)); + pwd->level_table[didx] = alloc(n * sizeof(uint16_t)); i = 2; level = 1; k = 0; @@ -1197,7 +1197,7 @@ next_buffer: if (fn->min_iqs > len) goto success; out_size = WMA_OUTPUT_BUFFER_SIZE; - out = para_malloc(out_size); + out = alloc(out_size); ret = wma_decode_superframe(pwd, out, &out_size, (uint8_t *)in + WMA_FRAME_SKIP); if (ret < 0) { diff --git a/write_common.c b/write_common.c index 41c3eb23..aec776a0 100644 --- a/write_common.c +++ b/write_common.c @@ -85,7 +85,7 @@ int check_writer_arg_or_die(const char *wa, struct lls_parse_result **lprp) if (!wa || !*wa) { writer_num = default_writer_id(); cmd = WRITE_CMD(writer_num); - argv = para_malloc(2 * sizeof(char *)); + argv = alloc(2 * sizeof(char *)); argc = 1; argv[0] = para_strdup(lls_command_name(cmd)); argv[1] = NULL; diff --git a/yy/mp.y b/yy/mp.y index 06d76101..f94d2408 100644 --- a/yy/mp.y +++ b/yy/mp.y @@ -59,7 +59,7 @@ enum semantic_types { static struct mp_ast_node *ast_node_raw(int id) { - struct mp_ast_node *node = para_malloc(sizeof(struct mp_ast_node)); + struct mp_ast_node *node = alloc(sizeof(struct mp_ast_node)); node->id = id; return node; } @@ -76,7 +76,7 @@ static struct mp_ast_node *ast_node_new_unary(int id, struct mp_ast_node *child) { struct mp_ast_node *node = ast_node_raw(id); node->num_children = 1; - node->children = para_malloc(sizeof(struct mp_ast_node *)); + node->children = alloc(sizeof(struct mp_ast_node *)); node->children[0] = child; return node; } @@ -86,7 +86,7 @@ static struct mp_ast_node *ast_node_new_binary(int id, struct mp_ast_node *left, { struct mp_ast_node *node = ast_node_raw(id); node->num_children = 2; - node->children = para_malloc(2 * sizeof(struct mp_ast_node *)); + node->children = alloc(2 * sizeof(struct mp_ast_node *)); node->children[0] = left; node->children[1] = right; return node; -- 2.39.2