Browse Source

rename nfcalloc() => nfzalloc()

the signature is like that of zalloc() (as found in the linux kernel;
not to be confused with zone allocators, etc.), not like that of
calloc().
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
08a375ea07
  1. 2
      src/common.h
  2. 2
      src/config.c
  3. 8
      src/drv_imap.c
  4. 4
      src/drv_maildir.c
  5. 2
      src/drv_proxy.c
  6. 2
      src/main.c
  7. 6
      src/socket.c
  8. 12
      src/sync.c
  9. 2
      src/util.c

2
src/common.h

@ -174,7 +174,7 @@ time_t timegm( struct tm *tm );
#endif #endif
void *nfmalloc( size_t sz ); void *nfmalloc( size_t sz );
void *nfcalloc( size_t sz ); void *nfzalloc( size_t sz );
void *nfrealloc( void *mem, size_t sz ); void *nfrealloc( void *mem, size_t sz );
char *nfstrndup( const char *str, size_t nchars ); char *nfstrndup( const char *str, size_t nchars );
char *nfstrdup( const char *str ); char *nfstrdup( const char *str );

2
src/config.c

@ -395,7 +395,7 @@ load_config( const char *where )
} }
} }
if (!strcasecmp( "Channel", cfile.cmd )) { if (!strcasecmp( "Channel", cfile.cmd )) {
channel = nfcalloc( sizeof(*channel) ); channel = nfzalloc( sizeof(*channel) );
channel->name = nfstrdup( cfile.val ); channel->name = nfstrdup( cfile.val );
channel->max_messages = global_conf.max_messages; channel->max_messages = global_conf.max_messages;
channel->expire_unread = global_conf.expire_unread; channel->expire_unread = global_conf.expire_unread;

8
src/drv_imap.c

@ -1208,7 +1208,7 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s ATTR_UNUSED )
// Workaround for server not sending UIDNEXT and/or APPENDUID. // Workaround for server not sending UIDNEXT and/or APPENDUID.
ctx->uidnext = uid + 1; ctx->uidnext = uid + 1;
} else if (ctx->fetch_sts == FetchMsgs) { } else if (ctx->fetch_sts == FetchMsgs) {
cur = nfcalloc( sizeof(*cur) ); cur = nfzalloc( sizeof(*cur) );
*ctx->msgapp = cur; *ctx->msgapp = cur;
ctx->msgapp = &cur->next; ctx->msgapp = &cur->next;
cur->uid = uid; cur->uid = uid;
@ -1933,7 +1933,7 @@ imap_alloc_store( store_conf_t *conf, const char *label )
} }
/* Finally, schedule opening a new server connection. */ /* Finally, schedule opening a new server connection. */
ctx = nfcalloc( sizeof(*ctx) ); ctx = nfzalloc( sizeof(*ctx) );
ctx->driver = &imap_driver; ctx->driver = &imap_driver;
ctx->ref_count = 1; ctx->ref_count = 1;
socket_init( &ctx->conn, &srvc->sconf, socket_init( &ctx->conn, &srvc->sconf,
@ -3502,7 +3502,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep )
int require_cram = -1; int require_cram = -1;
if (!strcasecmp( "IMAPAccount", cfg->cmd )) { if (!strcasecmp( "IMAPAccount", cfg->cmd )) {
server = nfcalloc( sizeof(*server) ); server = nfzalloc( sizeof(*server) );
name = server->name = nfstrdup( cfg->val ); name = server->name = nfstrdup( cfg->val );
*serverapp = server; *serverapp = server;
serverapp = &server->next; serverapp = &server->next;
@ -3510,7 +3510,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep )
*storep = NULL; *storep = NULL;
type = "IMAP account"; type = "IMAP account";
} else if (!strcasecmp( "IMAPStore", cfg->cmd )) { } else if (!strcasecmp( "IMAPStore", cfg->cmd )) {
store = nfcalloc( sizeof(*store) ); store = nfzalloc( sizeof(*store) );
store->driver = &imap_driver; store->driver = &imap_driver;
name = store->name = nfstrdup( cfg->val ); name = store->name = nfstrdup( cfg->val );
store->use_namespace = 1; store->use_namespace = 1;

4
src/drv_maildir.c

@ -208,7 +208,7 @@ maildir_alloc_store( store_conf_t *gconf, const char *label ATTR_UNUSED )
{ {
maildir_store_t *ctx; maildir_store_t *ctx;
ctx = nfcalloc( sizeof(*ctx) ); ctx = nfzalloc( sizeof(*ctx) );
ctx->driver = &maildir_driver; ctx->driver = &maildir_driver;
ctx->gen.conf = gconf; ctx->gen.conf = gconf;
ctx->uvfd = -1; ctx->uvfd = -1;
@ -1870,7 +1870,7 @@ maildir_parse_store( conffile_t *cfg, store_conf_t **storep )
if (strcasecmp( "MaildirStore", cfg->cmd )) if (strcasecmp( "MaildirStore", cfg->cmd ))
return 0; return 0;
store = nfcalloc( sizeof(*store) ); store = nfzalloc( sizeof(*store) );
store->info_delimiter = FieldDelimiter; store->info_delimiter = FieldDelimiter;
store->driver = &maildir_driver; store->driver = &maildir_driver;
store->name = nfstrdup( cfg->val ); store->name = nfstrdup( cfg->val );

2
src/drv_proxy.c

@ -389,7 +389,7 @@ proxy_alloc_store( store_t *real_ctx, const char *label )
{ {
proxy_store_t *ctx; proxy_store_t *ctx;
ctx = nfcalloc( sizeof(*ctx) ); ctx = nfzalloc( sizeof(*ctx) );
ctx->driver = &proxy_driver; ctx->driver = &proxy_driver;
ctx->gen.conf = real_ctx->conf; ctx->gen.conf = real_ctx->conf;
ctx->ref_count = 1; ctx->ref_count = 1;

2
src/main.c

@ -284,7 +284,7 @@ typedef struct chan_ent {
static chan_ent_t * static chan_ent_t *
add_channel( chan_ent_t ***chanapp, channel_conf_t *chan, int ops[] ) add_channel( chan_ent_t ***chanapp, channel_conf_t *chan, int ops[] )
{ {
chan_ent_t *ce = nfcalloc( sizeof(*ce) ); chan_ent_t *ce = nfzalloc( sizeof(*ce) );
ce->conf = chan; ce->conf = chan;
merge_actions( chan, ops, XOP_HAVE_TYPE, OP_MASK_TYPE, OP_MASK_TYPE ); merge_actions( chan, ops, XOP_HAVE_TYPE, OP_MASK_TYPE, OP_MASK_TYPE );

6
src/socket.c

@ -382,7 +382,7 @@ socket_start_deflate( conn_t *conn )
{ {
int result; int result;
conn->in_z = nfcalloc( sizeof(*conn->in_z) ); conn->in_z = nfzalloc( sizeof(*conn->in_z) );
result = inflateInit2( result = inflateInit2(
conn->in_z, conn->in_z,
-15 /* Use raw deflate */ -15 /* Use raw deflate */
@ -392,7 +392,7 @@ socket_start_deflate( conn_t *conn )
abort(); abort();
} }
conn->out_z = nfcalloc( sizeof(*conn->out_z) ); conn->out_z = nfzalloc( sizeof(*conn->out_z) );
result = deflateInit2( result = deflateInit2(
conn->out_z, conn->out_z,
Z_DEFAULT_COMPRESSION, /* Compression level */ Z_DEFAULT_COMPRESSION, /* Compression level */
@ -454,7 +454,7 @@ init_addrinfo( struct hostent *he )
uint naddr = 0; uint naddr = 0;
for (char **addr = he->h_addr_list; *addr; addr++) for (char **addr = he->h_addr_list; *addr; addr++)
naddr++; naddr++;
struct addr_info *caddr = nfcalloc( naddr * sizeof(struct addrinfo) ); struct addr_info *caddr = nfzalloc( naddr * sizeof(struct addrinfo) );
struct addr_info *ret, **caddrp = &ret; struct addr_info *ret, **caddrp = &ret;
for (char **addr = he->h_addr_list; *addr; addr++, caddr++) { for (char **addr = he->h_addr_list; *addr; addr++, caddr++) {
caddr->ai_addr->sin_family = AF_INET; caddr->ai_addr->sin_family = AF_INET;

12
src/sync.c

@ -662,7 +662,7 @@ static sync_rec_t *
upgrade_srec( sync_vars_t *svars, sync_rec_t *srec ) upgrade_srec( sync_vars_t *svars, sync_rec_t *srec )
{ {
// Create an entry and append it to the current one. // Create an entry and append it to the current one.
sync_rec_t *nsrec = nfcalloc( sizeof(*nsrec) ); sync_rec_t *nsrec = nfzalloc( sizeof(*nsrec) );
nsrec->next = srec->next; nsrec->next = srec->next;
srec->next = nsrec; srec->next = nsrec;
if (svars->srecadd == &srec->next) if (svars->srecadd == &srec->next)
@ -870,7 +870,7 @@ load_state( sync_vars_t *svars )
error( "Error: invalid sync state entry at %s:%d\n", svars->dname, line ); error( "Error: invalid sync state entry at %s:%d\n", svars->dname, line );
goto jbail; goto jbail;
} }
srec = nfcalloc( sizeof(*srec) ); srec = nfzalloc( sizeof(*srec) );
srec->uid[F] = t1; srec->uid[F] = t1;
srec->uid[N] = t2; srec->uid[N] = t2;
s = fbuf; s = fbuf;
@ -991,7 +991,7 @@ load_state( sync_vars_t *svars )
svars->uidval[F] = t1; svars->uidval[F] = t1;
svars->uidval[N] = t2; svars->uidval[N] = t2;
} else if (c == '+') { } else if (c == '+') {
srec = nfcalloc( sizeof(*srec) ); srec = nfzalloc( sizeof(*srec) );
srec->uid[F] = t1; srec->uid[F] = t1;
srec->uid[N] = t2; srec->uid[N] = t2;
debug( " new entry(%u,%u)\n", t1, t2 ); debug( " new entry(%u,%u)\n", t1, t2 );
@ -1105,7 +1105,7 @@ sync_boxes( store_t *ctx[], const char * const names[], int present[], channel_c
sync_vars_t *svars; sync_vars_t *svars;
int t; int t;
svars = nfcalloc( sizeof(*svars) ); svars = nfzalloc( sizeof(*svars) );
svars->t[1] = 1; svars->t[1] = 1;
svars->ref_count = 1; svars->ref_count = 1;
svars->cb = cb; svars->cb = cb;
@ -1504,7 +1504,7 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
debug( "matching messages on %s against sync records\n", str_fn[t] ); debug( "matching messages on %s against sync records\n", str_fn[t] );
hashsz = bucketsForSize( svars->nsrecs * 3 ); hashsz = bucketsForSize( svars->nsrecs * 3 );
srecmap = nfcalloc( hashsz * sizeof(*srecmap) ); srecmap = nfzalloc( hashsz * sizeof(*srecmap) );
for (srec = svars->srecs; srec; srec = srec->next) { for (srec = svars->srecs; srec; srec = srec->next) {
if (srec->status & S_DEAD) if (srec->status & S_DEAD)
continue; continue;
@ -1787,7 +1787,7 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
continue; continue;
} }
srec = nfcalloc( sizeof(*srec) ); srec = nfzalloc( sizeof(*srec) );
*svars->srecadd = srec; *svars->srecadd = srec;
svars->srecadd = &srec->next; svars->srecadd = &srec->next;
svars->nsrecs++; svars->nsrecs++;

2
src/util.c

@ -405,7 +405,7 @@ nfmalloc( size_t sz )
} }
void * void *
nfcalloc( size_t sz ) nfzalloc( size_t sz )
{ {
void *ret; void *ret;

Loading…
Cancel
Save