Bump copyright year
[privoxy.git] / miscutil.c
index bbfba61..aebd55f 100644 (file)
@@ -1,4 +1,4 @@
-const char miscutil_rcs[] = "$Id: miscutil.c,v 1.76 2012/03/09 17:55:50 fabiankeil Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 1.79 2015/08/12 10:34:38 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/miscutil.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/miscutil.c,v $
@@ -8,7 +8,7 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.76 2012/03/09 17:55:50 fabianke
  *                to deserve their own file but don't really fit in
  *                any other file.
  *
  *                to deserve their own file but don't really fit in
  *                any other file.
  *
- * Copyright   :  Written by and Copyright (C) 2001-2012 the
+ * Copyright   :  Written by and Copyright (C) 2001-2016 the
  *                Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
  *                Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
@@ -151,6 +151,14 @@ void *malloc_or_die(size_t buffer_size)
 {
    char *new_buf;
 
 {
    char *new_buf;
 
+   if (buffer_size == 0)
+   {
+      log_error(LOG_LEVEL_ERROR,
+         "malloc_or_die() called with buffer size 0");
+      assert(buffer_size != 0);
+      buffer_size = 4096;
+   }
+
    new_buf = malloc(buffer_size);
 
    if (new_buf == NULL)
    new_buf = malloc(buffer_size);
 
    if (new_buf == NULL)
@@ -524,6 +532,31 @@ char *string_toupper(const char *string)
 }
 
 
 }
 
 
+/*********************************************************************
+ *
+ * Function    :  string_move
+ *
+ * Description :  memmove wrapper to move the last part of a string
+ *                towards the beginning, overwriting the part in
+ *                the middle. strlcpy() can't be used here as the
+ *                strings overlap.
+ *
+ * Parameters  :
+ *          1  :  dst = Destination to overwrite
+ *          2  :  src = Source to move.
+ *
+ * Returns     :  N/A
+ *
+ *********************************************************************/
+void string_move(char *dst, char *src)
+{
+   assert(dst < src);
+
+   /* +1 to copy the terminating nul as well. */
+   memmove(dst, src, strlen(src)+1);
+}
+
+
 /*********************************************************************
  *
  * Function    :  bindup
 /*********************************************************************
  *
  * Function    :  bindup