current actions.c, 1.95, 1.96 cgiedit.c, 1.87, 1.88 cgisimple.c, 1.132, 1.133 deanimate.c, 1.23, 1.24 errlog.c, 1.125, 1.126 filters.c, 1.199, 1.200 jcc.c, 1.440, 1.441 loadcfg.c, 1.145, 1.146 loaders.c, 1.100, 1.101 urlmatch.c, 1.86, 1.87
Fabian Keil <[email protected]>
| Newsgroups | gmane.comp.web.privoxy.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27189
Modified Files:
actions.c cgiedit.c cgisimple.c deanimate.c errlog.c filters.c
jcc.c loadcfg.c loaders.c urlmatch.c
Log Message:
Start using zalloc_or_die()
While at it, get rid of lots of pointless explicit casts.
Index: deanimate.c
===================================================================
RCS file: /cvsroot/ijbswa/current/deanimate.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** deanimate.c 9 Mar 2012 16:24:36 -0000 1.23
--- deanimate.c 26 Feb 2016 12:29:38 -0000 1.24
***************
*** 368,375 ****
* Reserve a buffer for the current image block
*/
! if (NULL == (image = (struct binbuffer *)zalloc(sizeof(*image))))
! {
! return 1;
! }
/*
--- 368,372 ----
* Reserve a buffer for the current image block
*/
! image = zalloc_or_die(sizeof(*image));
/*
Index: cgiedit.c
===================================================================
RCS file: /cvsroot/ijbswa/current/cgiedit.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** cgiedit.c 18 Oct 2014 11:31:52 -0000 1.87
--- cgiedit.c 26 Feb 2016 12:29:38 -0000 1.88
***************
*** 1220,1231 ****
}
! if ((new_alias = zalloc(sizeof(*new_alias))) == NULL)
! {
! /* Out of memory */
! free(name);
! free(value);
! free_alias_list(alias_list);
! return JB_ERR_MEMORY;
! }
err = get_actions(value, alias_list, new_alias->action);
--- 1220,1224 ----
}
! new_alias = zalloc_or_die(sizeof(*new_alias));
err = get_actions(value, alias_list, new_alias->action);
***************
*** 1395,1403 ****
*pfile = NULL;
! cur_line = first_line = zalloc(sizeof(struct file_line));
! if (cur_line == NULL)
! {
! return JB_ERR_MEMORY;
! }
cur_line->type = FILE_LINE_UNPROCESSED;
--- 1388,1392 ----
*pfile = NULL;
! cur_line = first_line = zalloc_or_die(sizeof(struct file_line));
cur_line->type = FILE_LINE_UNPROCESSED;
***************
*** 1415,1425 ****
{
prev_line = cur_line;
! cur_line = prev_line->next = zalloc(sizeof(struct file_line));
! if (cur_line == NULL)
! {
! /* Out of memory */
! edit_free_file_lines(first_line);
! return JB_ERR_MEMORY;
! }
cur_line->type = FILE_LINE_UNPROCESSED;
--- 1404,1408 ----
{
prev_line = cur_line;
! cur_line = prev_line->next = zalloc_or_die(sizeof(struct file_line));
cur_line->type = FILE_LINE_UNPROCESSED;
***************
*** 1551,1560 ****
}
! file = (struct editable_file *) zalloc(sizeof(*file));
! if (file == NULL)
! {
! edit_free_file_lines(lines);
! return err;
! }
file->lines = lines;
--- 1534,1538 ----
}
! file = zalloc_or_die(sizeof(*file));
file->lines = lines;
***************
*** 3436,3446 ****
/* Allocate the new line */
! new_line = (struct file_line *)zalloc(sizeof(*new_line));
! if (new_line == NULL)
! {
! free(new_pattern);
! edit_free_file(file);
! return JB_ERR_MEMORY;
! }
/* Fill in the data members of the new line */
--- 3414,3418 ----
/* Allocate the new line */
! new_line = zalloc_or_die(sizeof(*new_line));
/* Fill in the data members of the new line */
***************
*** 3829,3839 ****
/* Allocate the new line */
! new_line = (struct file_line *)zalloc(sizeof(*new_line));
! if (new_line == NULL)
! {
! free(new_text);
! edit_free_file(file);
! return JB_ERR_MEMORY;
! }
/* Fill in the data members of the new line */
--- 3801,3805 ----
/* Allocate the new line */
! new_line = zalloc_or_die(sizeof(*new_line));
/* Fill in the data members of the new line */
Index: loaders.c
===================================================================
RCS file: /cvsroot/ijbswa/current/loaders.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -C2 -d -r1.100 -r1.101
*** loaders.c 24 Jan 2015 16:40:21 -0000 1.100
--- loaders.c 26 Feb 2016 12:29:38 -0000 1.101
***************
*** 289,300 ****
}
! fs = (struct file_list *)zalloc(sizeof(struct file_list));
! if (fs == NULL)
! {
! /* Out of memory error */
! return 1;
! }
!
!
fs->filename = strdup(filename);
fs->lastmodified = statbuf->st_mtime;
--- 289,293 ----
}
! fs = zalloc_or_die(sizeof(struct file_list));
fs->filename = strdup(filename);
fs->lastmodified = statbuf->st_mtime;
***************
*** 849,857 ****
}
! fs->f = bl = (struct block_spec *)zalloc(sizeof(*bl));
! if (bl == NULL)
! {
! goto load_trustfile_error;
! }
if ((fp = fopen(csp->config->trustfile, "r")) == NULL)
--- 842,846 ----
}
! fs->f = bl = zalloc_or_die(sizeof(*bl));
if ((fp = fopen(csp->config->trustfile, "r")) == NULL)
***************
*** 896,904 ****
/* allocate a new node */
! if ((b = zalloc(sizeof(*b))) == NULL)
! {
! fclose(fp);
! goto load_trustfile_error;
! }
/* add it to the list */
--- 885,889 ----
/* allocate a new node */
! b = zalloc_or_die(sizeof(*b));
/* add it to the list */
***************
*** 1184,1192 ****
if (new_filter != FT_INVALID_FILTER)
{
! new_bl = (struct re_filterfile_spec *)zalloc(sizeof(*bl));
! if (new_bl == NULL)
! {
! goto load_re_filterfile_error;
! }
if (new_filter == FT_CONTENT_FILTER)
{
--- 1169,1173 ----
if (new_filter != FT_INVALID_FILTER)
{
! new_bl = zalloc_or_die(sizeof(*bl));
if (new_filter == FT_CONTENT_FILTER)
{
Index: jcc.c
===================================================================
RCS file: /cvsroot/ijbswa/current/jcc.c,v
retrieving revision 1.440
retrieving revision 1.441
diff -C2 -d -r1.440 -r1.441
*** jcc.c 16 Jan 2016 12:33:36 -0000 1.440
--- jcc.c 26 Feb 2016 12:29:38 -0000 1.441
***************
*** 3967,3977 ****
#endif
! csp_list = (struct client_states *)zalloc(sizeof(*csp_list));
! if (NULL == csp_list)
! {
! log_error(LOG_LEVEL_FATAL,
! "malloc(%d) for csp_list failed: %E", sizeof(*csp_list));
! continue;
! }
csp = &csp_list->csp;
--- 3967,3971 ----
#endif
! csp_list = zalloc_or_die(sizeof(*csp_list));
csp = &csp_list->csp;
Index: urlmatch.c
===================================================================
RCS file: /cvsroot/ijbswa/current/urlmatch.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -C2 -d -r1.86 -r1.87
*** urlmatch.c 27 Dec 2015 12:47:17 -0000 1.86
--- urlmatch.c 26 Feb 2016 12:29:39 -0000 1.87
***************
*** 618,622 ****
*
* Returns : JB_ERR_OK - Success
- * JB_ERR_MEMORY - Out of memory
* JB_ERR_PARSE - Cannot parse regex
*
--- 618,621 ----
***************
*** 657,666 ****
}
! *regex = zalloc(sizeof(**regex));
! if (NULL == *regex)
! {
! free_pattern_spec(url);
! return JB_ERR_MEMORY;
! }
snprintf(rebuf, sizeof(rebuf), fmt, pattern);
--- 656,660 ----
}
! *regex = zalloc_or_die(sizeof(**regex));
snprintf(rebuf, sizeof(rebuf), fmt, pattern);
Index: cgisimple.c
===================================================================
RCS file: /cvsroot/ijbswa/current/cgisimple.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -C2 -d -r1.132 -r1.133
*** cgisimple.c 6 Nov 2015 13:38:13 -0000 1.132
--- cgisimple.c 26 Feb 2016 12:29:38 -0000 1.133
***************
*** 1986,1995 ****
}
! *buffer = (char *)zalloc(*length + 1);
! if (NULL == *buffer)
! {
! err = JB_ERR_MEMORY;
! }
! else if (1 != fread(*buffer, *length, 1, fp))
{
/*
--- 1986,1992 ----
}
! *buffer = zalloc_or_die(*length + 1);
!
! if (1 != fread(*buffer, *length, 1, fp))
{
/*
Index: errlog.c
===================================================================
RCS file: /cvsroot/ijbswa/current/errlog.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -C2 -d -r1.125 -r1.126
*** errlog.c 26 Jan 2016 17:12:14 -0000 1.125
--- errlog.c 26 Feb 2016 12:29:38 -0000 1.126
***************
*** 717,729 ****
if (NULL == outbuf_save)
{
! outbuf_save = (char*)zalloc(log_buffer_size + 1); /* +1 for paranoia */
! if (NULL == outbuf_save)
! {
! snprintf(tempbuf, sizeof(tempbuf),
! "%s %08lx Fatal error: Out of memory in log_error().",
! timestamp, thread_id);
! fatal_error(tempbuf); /* Exit */
! return;
! }
}
outbuf = outbuf_save;
--- 717,721 ----
if (NULL == outbuf_save)
{
! outbuf_save = zalloc_or_die(log_buffer_size + 1); /* +1 for paranoia */
}
outbuf = outbuf_save;
Index: filters.c
===================================================================
RCS file: /cvsroot/ijbswa/current/filters.c,v
retrieving revision 1.199
retrieving revision 1.200
diff -C2 -d -r1.199 -r1.200
*** filters.c 16 Jan 2016 12:33:35 -0000 1.199
--- filters.c 26 Feb 2016 12:29:38 -0000 1.200
***************
*** 1955,1964 ****
size = (size_t)(csp->iob->eod - csp->iob->cur);
! if ( (NULL == (in = (struct binbuffer *)zalloc(sizeof *in )))
! || (NULL == (out = (struct binbuffer *)zalloc(sizeof *out))) )
! {
! log_error(LOG_LEVEL_DEANIMATE, "failed! (no mem)");
! return NULL;
! }
in->buffer = csp->iob->cur;
--- 1955,1960 ----
size = (size_t)(csp->iob->eod - csp->iob->cur);
! in = zalloc_or_die(sizeof(*in));
! out = zalloc_or_die(sizeof(*out));
in->buffer = csp->iob->cur;
***************
*** 2425,2436 ****
* in csp as well, so sweep() can free it later on.
*/
! fwd = csp->fwd = zalloc(sizeof(*fwd));
! if (NULL == fwd)
! {
! log_error(LOG_LEVEL_FATAL,
! "can't allocate memory for forward-override{%s}", forward_override_line);
! /* Never get here - LOG_LEVEL_FATAL causes program exit */
! return NULL;
! }
vec_count = ssplit(forward_settings, " \t", vec, SZ(vec));
--- 2421,2425 ----
* in csp as well, so sweep() can free it later on.
*/
! fwd = csp->fwd = zalloc_or_die(sizeof(*fwd));
vec_count = ssplit(forward_settings, " \t", vec, SZ(vec));
Index: loadcfg.c
===================================================================
RCS file: /cvsroot/ijbswa/current/loadcfg.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -C2 -d -r1.145 -r1.146
*** loadcfg.c 16 Jan 2016 12:33:36 -0000 1.145
--- loadcfg.c 26 Feb 2016 12:29:38 -0000 1.146
***************
*** 485,497 ****
#endif /* def FEATURE_TOGGLE */
! fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
!
! if (NULL == config)
! {
! freez(fs->filename);
! freez(fs);
! log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
! return NULL;
! }
/*
--- 485,489 ----
#endif /* def FEATURE_TOGGLE */
! fs->f = config = zalloc_or_die(sizeof(*config));
/*
***************
*** 767,778 ****
/* allocate a new node */
! cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
!
! if (cur_acl == NULL)
! {
! log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
! /* Never get here - LOG_LEVEL_FATAL causes program exit */
! break;
! }
cur_acl->action = ACL_DENY;
--- 759,763 ----
/* allocate a new node */
! cur_acl = zalloc_or_die(sizeof(*cur_acl));
cur_acl->action = ACL_DENY;
***************
*** 965,976 ****
/* allocate a new node */
! cur_fwd = zalloc(sizeof(*cur_fwd));
! if (cur_fwd == NULL)
! {
! log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
! /* Never get here - LOG_LEVEL_FATAL causes program exit */
! break;
! }
!
cur_fwd->type = SOCKS_NONE;
--- 950,954 ----
/* allocate a new node */
! cur_fwd = zalloc_or_die(sizeof(*cur_fwd));
cur_fwd->type = SOCKS_NONE;
***************
*** 1021,1032 ****
/* allocate a new node */
! cur_fwd = zalloc(sizeof(*cur_fwd));
! if (cur_fwd == NULL)
! {
! log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
! /* Never get here - LOG_LEVEL_FATAL causes program exit */
! break;
! }
!
cur_fwd->type = SOCKS_4;
--- 999,1003 ----
/* allocate a new node */
! cur_fwd = zalloc_or_die(sizeof(*cur_fwd));
cur_fwd->type = SOCKS_4;
***************
*** 1093,1103 ****
/* allocate a new node */
! cur_fwd = zalloc(sizeof(*cur_fwd));
! if (cur_fwd == NULL)
! {
! log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
! /* Never get here - LOG_LEVEL_FATAL causes program exit */
! break;
! }
if (directive_hash == hash_forward_socks4a)
--- 1064,1068 ----
/* allocate a new node */
! cur_fwd = zalloc_or_die(sizeof(*cur_fwd));
if (directive_hash == hash_forward_socks4a)
***************
*** 1292,1303 ****
/* allocate a new node */
! cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
!
! if (cur_acl == NULL)
! {
! log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
! /* Never get here - LOG_LEVEL_FATAL causes program exit */
! break;
! }
cur_acl->action = ACL_PERMIT;
--- 1257,1261 ----
/* allocate a new node */
! cur_acl = zalloc_or_die(sizeof(*cur_acl));
cur_acl->action = ACL_PERMIT;
***************
*** 1759,1763 ****
* Need to set up a fake csp, so they can get to the config.
*/
! fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
fake_csp->config = config;
--- 1717,1721 ----
* Need to set up a fake csp, so they can get to the config.
*/
! fake_csp = zalloc_or_die(sizeof(*fake_csp));
fake_csp->config = config;
Index: actions.c
===================================================================
RCS file: /cvsroot/ijbswa/current/actions.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -C2 -d -r1.95 -r1.96
*** actions.c 16 Jan 2016 12:33:35 -0000 1.95
--- actions.c 26 Feb 2016 12:29:38 -0000 1.96
***************
*** 1213,1223 ****
}
! fs->f = last_perm = (struct url_actions *)zalloc(sizeof(*last_perm));
! if (last_perm == NULL)
! {
! log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': out of memory!",
! csp->config->actions_file[fileid]);
! return 1; /* never get here */
! }
if ((fp = fopen(csp->config->actions_file[fileid], "r")) == NULL)
--- 1213,1217 ----
}
! fs->f = last_perm = zalloc_or_die(sizeof(*last_perm));
if ((fp = fopen(csp->config->actions_file[fileid], "r")) == NULL)
***************
*** 1363,1375 ****
}
cur_action_used = 0;
! cur_action = (struct action_spec *)zalloc(sizeof(*cur_action));
! if (cur_action == NULL)
! {
! fclose(fp);
! log_error(LOG_LEVEL_FATAL,
! "can't load actions file '%s': out of memory",
! csp->config->actions_file[fileid]);
! return 1; /* never get here */
! }
init_action(cur_action);
--- 1357,1361 ----
}
cur_action_used = 0;
! cur_action = zalloc_or_die(sizeof(*cur_action));
init_action(cur_action);
***************
*** 1487,1498 ****
}
! if ((new_alias = zalloc(sizeof(*new_alias))) == NULL)
! {
! fclose(fp);
! log_error(LOG_LEVEL_FATAL,
! "can't load actions file '%s': out of memory!",
! csp->config->actions_file[fileid]);
! return 1; /* never get here */
! }
/* Eat any the whitespace before the '=' */
--- 1473,1477 ----
}
! new_alias = zalloc_or_die(sizeof(*new_alias));
/* Eat any the whitespace before the '=' */
***************
*** 1545,1556 ****
/* allocate a new node */
! if ((perm = zalloc(sizeof(*perm))) == NULL)
! {
! fclose(fp);
! log_error(LOG_LEVEL_FATAL,
! "can't load actions file '%s': out of memory!",
! csp->config->actions_file[fileid]);
! return 1; /* never get here */
! }
perm->action = cur_action;
--- 1524,1528 ----
/* allocate a new node */
! perm = zalloc_or_die(sizeof(*perm));
perm->action = cur_action;
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140