static void aacdec_open(struct filter_node *fn)
{
NeAACDecConfigurationPtr c;
- struct private_aacdec_data *padd = para_calloc(sizeof(*padd));
+ struct private_aacdec_data *padd = zalloc(sizeof(*padd));
padd->handle = NeAACDecOpen();
c = NeAACDecGetCurrentConfiguration(padd->handle);
if (!fn || *fn == '\0')
return -E_AFH_RECV_BAD_FILENAME;
- rn->private_data = pard = para_calloc(sizeof(*pard));
+ rn->private_data = pard = zalloc(sizeof(*pard));
afhi = &pard->afhi;
ret = mmap_full_file(fn, O_RDONLY, &pard->map,
&pard->map_size, &pard->fd);
PARA_INFO_LOG("snd_mixer_{open,attach,register,load}\n");
*handle = NULL;
- h = para_calloc(sizeof(*h));
+ h = zalloc(sizeof(*h));
h->card = para_strdup(dev? dev : "hw:0");
ret = snd_mixer_open(&h->mixer, 0);
if (ret < 0) {
if (bytes == 0) /* no data available */
return 0;
- pad = wn->private_data = para_calloc(sizeof(*pad));
+ pad = wn->private_data = zalloc(sizeof(*pad));
ret = get_btr_sample_rate(btrn, &val);
if (ret < 0)
goto err;
static void amp_open(struct filter_node *fn)
{
- struct private_amp_data *pad = para_calloc(sizeof(*pad));
+ struct private_amp_data *pad = zalloc(sizeof(*pad));
unsigned given = FILTER_CMD_OPT_GIVEN(AMP, AMP, fn->lpr);
uint32_t amp_arg = FILTER_CMD_OPT_UINT32_VAL(AMP, AMP, fn->lpr);
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];
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;
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)
ret = dup(fd);
if (ret < 0)
return -ERRNO_TO_PARA_ERROR(errno);
- new_client = para_calloc(sizeof(*new_client));
+ new_client = zalloc(sizeof(*new_client));
new_client->fd = ret;
PARA_INFO_LOG("adding client on fd %d\n", new_client->fd);
new_client->item_mask = mask;
*/
static struct btr_buffer *new_btrb(char *buf, size_t size)
{
- struct btr_buffer *btrb = para_calloc(sizeof(*btrb));
+ struct btr_buffer *btrb = zalloc(sizeof(*btrb));
btrb->buf = buf;
btrb->size = size;
if (btrn->start.tv_sec == 0)
btrn->start = *now;
FOR_EACH_CHILD(ch, btrn) {
- struct btr_buffer_reference *br = para_calloc(sizeof(*br));
+ struct btr_buffer_reference *br = zalloc(sizeof(*br));
br->btrb = btrb;
br->consumed = consumed;
list_add_tail(&br->node, &ch->input_queue);
buf1, sz1, buf2, sz2, buf, sz);
memcpy(buf, buf1, sz1);
memcpy(buf + sz1, buf2, sz2);
- br = para_calloc(sizeof(*br));
+ br = zalloc(sizeof(*br));
br->btrb = new_btrb(buf, sz);
br->btrb->refcount = 1;
br->consumed = 0;
memcpy(buf, bufs[0], szs[0]);
memcpy(buf + szs[0], bufs[1], szs[1]);
- br = para_calloc(sizeof(*br));
+ br = zalloc(sizeof(*br));
br->btrb = new_btrb(buf, sz);
br->btrb->refcount = 1;
struct btr_node *child, struct wav_params *params,
struct btr_node **cw_btrn)
{
- struct check_wav_context *cwc = para_calloc(sizeof(*cwc));
+ struct check_wav_context *cwc = zalloc(sizeof(*cwc));
cwc->state = CWS_NEED_HEADER;
cwc->min_iqs = WAV_HEADER_LEN;
PARA_INFO_LOG("user: %s\n", user);
PARA_INFO_LOG("key file: %s\n", kf);
PARA_INFO_LOG("loglevel: %d\n", ll);
- ct = para_calloc(sizeof(*ct));
+ ct = zalloc(sizeof(*ct));
ct->scc.fd = -1;
ct->lpr = lpr;
ct->key_file = kf;
static void compress_open(struct filter_node *fn)
{
- struct private_compress_data *pcd = para_calloc(sizeof(*pcd));
+ struct private_compress_data *pcd = zalloc(sizeof(*pcd));
uint32_t inertia = U32_OPTVAL(INERTIA, fn->lpr);
uint32_t aggressiveness = U32_OPTVAL(AGGRESSIVENESS, fn->lpr);
shutdown_client(sc, dss);
return;
}
- dfc = para_calloc(sizeof(*dfc));
+ dfc = zalloc(sizeof(*dfc));
sc->private_data = dfc;
k = OPT_UINT32_VAL(DCCP_DATA_SLICES_PER_GROUP);
n = OPT_UINT32_VAL(DCCP_SLICES_PER_GROUP);
slice = alloc(k * sizeof(unsigned char *));
for (row = 0; row < k; row++) {
if (idx[row] >= k) {
- slice[row] = para_calloc(sz);
+ slice[row] = zalloc(sz);
for (col = 0; col < k; col++)
addmul(slice[row], data[col],
m_dec[row * k + col], sz);
if (fg->num_slices == 0) {
fg->num_slices = fg->h.slices_per_group;
fg->idx = alloc(fg->num_slices * sizeof(int));
- fg->data = para_calloc(fg->num_slices * sizeof(unsigned char *));
+ fg->data = zalloc(fg->num_slices * sizeof(unsigned char *));
}
r = fg->num_received_slices;
/* Check if we already have this slice. */
static void fecdec_open(struct filter_node *fn)
{
struct private_fecdec_data *pfd;
- pfd = para_calloc(sizeof(*pfd));
+ pfd = zalloc(sizeof(*pfd));
fn->private_data = pfd;
fn->min_iqs = FEC_HEADER_SIZE;
}
close(fd);
return ret;
}
- pfwd = wn->private_data = para_calloc(sizeof(*pfwd));
+ pfwd = wn->private_data = zalloc(sizeof(*pfwd));
pfwd->fd = fd;
return 1;
}
struct filter_node *fn;
struct task_info ti;
- fn = fns[i] = para_calloc(sizeof(*fn));
+ fn = fns[i] = zalloc(sizeof(*fn));
fn->filter_num = filter_setup(fa, &fn->conf, &filter_lpr);
name = filter_name(fn->filter_num);
fn->lpr = filter_lpr;
FLAC__Metadata_Iterator *iter;
FLAC__StreamMetadata *b = NULL;
FLAC__bool ok;
- struct private_flac_afh_data *pfad = para_calloc(sizeof(*pfad));
+ struct private_flac_afh_data *pfad = zalloc(sizeof(*pfad));
pfad->map = map;
pfad->map_bytes = map_bytes;
static void flacdec_open(struct filter_node *fn)
{
- struct private_flacdec_data *pfd = para_calloc(sizeof(*pfd));
+ struct private_flacdec_data *pfd = zalloc(sizeof(*pfd));
fn->private_data = pfd;
fn->min_iqs = 0;
}
int grab_client_new(int fd, struct lls_parse_result *lpr, struct sched *s)
{
int ret;
- struct grab_client *gc = para_calloc(sizeof(struct grab_client));
+ struct grab_client *gc = zalloc(sizeof(struct grab_client));
ret = gc_check_args(lpr, gc);
if (ret < 0)
close(fd);
return ret;
}
- rn->private_data = phd = para_calloc(sizeof(struct private_http_recv_data));
+ rn->private_data = phd = zalloc(sizeof(struct private_http_recv_data));
rn->fd = fd;
phd->status = HTTP_CONNECTED;
rn->btrp = btr_pool_new("http_recv", 320 * 1024);
double alpha;
struct mdct_context *s;
- s = para_calloc(sizeof(*s));
+ s = zalloc(sizeof(*s));
n = 1 << nbits;
s->nbits = nbits;
s->n = n;
static struct mood *alloc_new_mood(const char *name)
{
- struct mood *m = para_calloc(sizeof(struct mood));
+ struct mood *m = zalloc(sizeof(struct mood));
if (name)
m->name = para_strdup(name);
return m;
*errmsg = NULL;
return 0;
}
- ctx = para_calloc(sizeof(*ctx));
+ ctx = zalloc(sizeof(*ctx));
ctx->errmsg = NULL;
ctx->ast = NULL;
static void mp3dec_open(struct filter_node *fn)
{
- struct private_mp3dec_data *pmd = para_calloc(sizeof(*pmd));
+ struct private_mp3dec_data *pmd = zalloc(sizeof(*pmd));
fn->private_data = pmd;
mad_stream_init(&pmd->stream);
*/
struct oac_custom_header *oac_custom_header_new(void)
{
- return para_calloc(sizeof(struct oac_custom_header));
+ return zalloc(sizeof(struct oac_custom_header));
}
/**
static void ogg_open(struct filter_node *fn)
{
- fn->private_data = para_calloc(sizeof(struct private_oggdec_data));
+ fn->private_data = zalloc(sizeof(struct private_oggdec_data));
fn->min_iqs = 8000;
}
static void opusdec_open(struct filter_node *fn)
{
- struct opusdec_context *ctx = para_calloc(sizeof(*ctx));
+ struct opusdec_context *ctx = zalloc(sizeof(*ctx));
ogg_sync_init(&ctx->oy);
fn->private_data = ctx;
{
int ret, format;
unsigned ch, rate;
- struct private_oss_write_data *powd = para_calloc(sizeof(*powd));
+ struct private_oss_write_data *powd = zalloc(sizeof(*powd));
const char *dev = WRITE_CMD_OPT_STRING_VAL(OSS, DEVICE, wn->lpr);
PARA_INFO_LOG("opening %s\n", dev);
session_open();
num_inputs = lls_num_inputs(play_lpr);
init_shuffle_map();
- pt->invalid = para_calloc(sizeof(*pt->invalid) * num_inputs);
+ pt->invalid = zalloc(sizeof(*pt->invalid) * num_inputs);
pt->rq = CRT_FILE_CHANGE;
pt->playing = true;
pt->task = task_register(&(struct task_info){
static void prebuffer_open(struct filter_node *fn)
{
- struct private_prebuffer_data *ppd = para_calloc(sizeof(*ppd));
+ struct private_prebuffer_data *ppd = zalloc(sizeof(*ppd));
fn->private_data = ppd;
}
static void resample_open(struct filter_node *fn)
{
- struct resample_context *ctx = para_calloc(sizeof(*ctx));
+ struct resample_context *ctx = zalloc(sizeof(*ctx));
struct btr_node *btrn = fn->btrn;
struct wav_params wp;
*/
struct ringbuffer *ringbuffer_new(unsigned size)
{
- struct ringbuffer *rb = para_calloc(sizeof(struct ringbuffer));
- rb->entries = para_calloc(size * sizeof(void *));
+ struct ringbuffer *rb = zalloc(sizeof(struct ringbuffer));
+ rb->entries = zalloc(size * sizeof(void *));
rb->size = size;
return rb;
}
if (ret < 0)
goto close_fd_and_warn;
ss->num_clients++;
- sc = para_calloc(sizeof(*sc));
+ sc = zalloc(sizeof(*sc));
sc->fd = fd;
sc->name = para_strdup(remote_name(fd));
sc->cq = cq_new(MAX_CQ_BYTES);
struct sb_context *sb_new_recv(size_t max_size, sb_transformation t,
void *trafo_context)
{
- struct sb_context *c = para_calloc(sizeof(*c));
+ struct sb_context *c = zalloc(sizeof(*c));
c->max_size = max_size;
c->trafo = t;
struct sb_context *sb_new_send(struct sb_buffer *sbb, bool dont_free,
sb_transformation t, void *trafo_context)
{
- struct sb_context *c = para_calloc(sizeof(*c));
+ struct sb_context *c = zalloc(sizeof(*c));
struct iovec src, dst, *srcp, *dstp;
assert(sbb);
ret = mark_fd_nonblocking(signal_pipe[1]);
if (ret < 0)
goto err_out;
- st = para_calloc(sizeof(*st));
+ st = zalloc(sizeof(*st));
st->fd = signal_pipe[0];
return st;
err_out:
static void spxdec_open(struct filter_node *fn)
{
- struct private_spxdec_data *psd = para_calloc(sizeof(*psd));
+ struct private_spxdec_data *psd = zalloc(sizeof(*psd));
fn->private_data = psd;
fn->min_iqs = 200;
}
/**
- * Paraslash's version of calloc().
+ * Allocate and initialize memory.
*
* \param size The desired new size.
*
- * A wrapper for calloc(3) which exits on errors.
- *
* \return A pointer to the allocated and zeroed-out memory, which is suitably
* aligned for any kind of variable.
*
- * \sa calloc(3)
+ * \sa \ref alloc(), calloc(3).
*/
-__must_check __malloc void *para_calloc(size_t size)
+__must_check __malloc void *zalloc(size_t size)
{
void *ret = alloc(size);
__must_check void *para_realloc(void *p, size_t size);
__must_check __malloc void *alloc(size_t size);
-__must_check __malloc void *para_calloc(size_t size);
+__must_check __malloc void *zalloc(size_t size);
__must_check __malloc char *para_strdup(const char *s);
__printf_2_0 unsigned xvasprintf(char **result, const char *fmt, va_list ap);
unsigned buddy_given;
const struct lls_opt_result *r_b;
- ctx = fn->private_data = para_calloc(sizeof(*ctx));
+ ctx = fn->private_data = zalloc(sizeof(*ctx));
init_list_head(&ctx->buddies);
/* create socket to listen for incoming packets */
sc->name);
return -E_TARGET_EXISTS;
}
- ut = para_calloc(sizeof(*ut));
- sc = para_calloc(sizeof(*sc));
+ ut = zalloc(sizeof(*ut));
+ sc = zalloc(sizeof(*sc));
ut->fcp.slices_per_group = scd->slices_per_group;
ut->fcp.data_slices_per_group = scd->data_slices_per_group;
ut->fcp.init_fec = udp_init_fec;
struct fec_client *vss_add_fec_client(struct sender_client *sc,
struct fec_client_parms *fcp)
{
- struct fec_client *fc = para_calloc(sizeof(*fc));
+ struct fec_client *fc = zalloc(sizeof(*fc));
fc->sc = sc;
fc->fcp = fcp;
int ret;
if (!src || !*src) {
- *dst = para_calloc(2);
+ *dst = zalloc(2);
return 0;
}
/*
int ret, i;
PARA_NOTICE_LOG("initial buf: %d bytes\n", len);
- pwd = para_calloc(sizeof(*pwd));
+ pwd = zalloc(sizeof(*pwd));
ret = read_asf_header(initial_buf, len, &pwd->ahi);
if (ret <= 0) {
free(pwd);
}, &s);
n = writer_given? writer_given : 1;
- wns = para_calloc(n * sizeof(*wns));
+ wns = zalloc(n * sizeof(*wns));
for (i = 0; i < n; i++) {
const char *arg = i < writer_given?
lls_string_val(i, OPT_RESULT(WRITER, lpr)) : NULL;