projects
/
privoxy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Streamline handle_established_connection()'s parameter list
[privoxy.git]
/
miscutil.c
diff --git
a/miscutil.c
b/miscutil.c
index
10ff9ea
..
010745f
100644
(file)
--- a/
miscutil.c
+++ b/
miscutil.c
@@
-1,4
+1,4
@@
-const char miscutil_rcs[] = "$Id: miscutil.c,v 1.8
1 2016/02/26 12:29:17
fabiankeil Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 1.8
5 2017/06/08 13:11:08
fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $
@@
-71,22
+71,28
@@
const char miscutil_h_rcs[] = MISCUTIL_H_VERSION;
*
* Function : zalloc
*
*
* Function : zalloc
*
- * Description : Malloc some memory and set it to '\0'.
+ * Description : Returns allocated memory that is initialized
+ * with zeros.
*
* Parameters :
* 1 : size = Size of memory chunk to return.
*
*
* Parameters :
* 1 : size = Size of memory chunk to return.
*
- * Returns : Pointer to newly
m
alloc'd memory chunk.
+ * Returns : Pointer to newly alloc'd memory chunk.
*
*********************************************************************/
void *zalloc(size_t size)
{
void * ret;
*
*********************************************************************/
void *zalloc(size_t size)
{
void * ret;
+#ifdef HAVE_CALLOC
+ ret = calloc(1, size);
+#else
+#warning calloc appears to be unavailable. Your platform will become unsupported in the future
if ((ret = (void *)malloc(size)) != NULL)
{
memset(ret, 0, size);
}
if ((ret = (void *)malloc(size)) != NULL)
{
memset(ret, 0, size);
}
+#endif
return(ret);
return(ret);
@@
-212,7
+218,8
@@
void *malloc_or_die(size_t buffer_size)
*
* Function : write_pid_file
*
*
* Function : write_pid_file
*
- * Description : Writes a pid file with the pid of the main process
+ * Description : Writes a pid file with the pid of the main process.
+ * Exits if the file can't be opened
*
* Parameters : None
*
*
* Parameters : None
*
@@
-231,7
+238,7
@@
void write_pid_file(void)
if ((fp = fopen(pidfile, "w")) == NULL)
{
if ((fp = fopen(pidfile, "w")) == NULL)
{
- log_error(LOG_LEVEL_
INFO
, "can't open pidfile '%s': %E", pidfile);
+ log_error(LOG_LEVEL_
FATAL
, "can't open pidfile '%s': %E", pidfile);
}
else
{
}
else
{
@@
-765,7
+772,9
@@
long int pick_from_range(long int range)
if (range <= 0) return 0;
if (range <= 0) return 0;
-#ifdef HAVE_RANDOM
+#ifdef HAVE_ARC4RANDOM
+ number = arc4random() % range + 1;
+#elif defined(HAVE_RANDOM)
number = random() % range + 1;
#elif defined(MUTEX_LOCKS_AVAILABLE)
privoxy_mutex_lock(&rand_mutex);
number = random() % range + 1;
#elif defined(MUTEX_LOCKS_AVAILABLE)
privoxy_mutex_lock(&rand_mutex);
@@
-789,7
+798,7
@@
long int pick_from_range(long int range)
"might cause crashes, predictable results or even combine these fine options.");
number = rand() % (long int)(range + 1);
"might cause crashes, predictable results or even combine these fine options.");
number = rand() % (long int)(range + 1);
-#endif /* (def HAVE_RANDOM) */
+#endif /* (def HAVE_
ARC4
RANDOM) */
return number;
}
return number;
}