]> sjero.net Git - wget/commitdiff
[svn] Make hash.c compilable outside the source tree.
authorhniksic <devnull@localhost>
Wed, 4 Feb 2004 12:32:46 +0000 (04:32 -0800)
committerhniksic <devnull@localhost>
Wed, 4 Feb 2004 12:32:46 +0000 (04:32 -0800)
src/ChangeLog
src/hash.c

index dacb4e7eeea4e30d7be1b1438fe19121125a6793..993f05bf939e0f9c63594f9e3cf627553edc1505 100644 (file)
@@ -1,3 +1,8 @@
+2004-02-04  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * hash.c: Make the file compilable outside Wget source tree when
+       -DSTANDALONE is used.
+
 2004-01-29  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * utils.c (determine_screen_width): Return 0 if not running on
index f86c67263e0095bbf10381e4a34b401cb7fbe50a..f3ebb0f37f709e358075bacf8435d920e6feab22 100644 (file)
@@ -27,39 +27,47 @@ modify this file, you may extend this exception to your version of the
 file, but you are not obligated to do so.  If you do not wish to do
 so, delete this exception statement from your version.  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+/* With -DSTANDALONE, this file can be compiled outside Wget source
+   tree.  To test, also use -DTEST.  */
 
-#ifdef HAVE_STRING_H
-# include <string.h>
+#ifndef STANDALONE
+# include <config.h>
+# ifdef HAVE_STRING_H
+#  include <string.h>
+# else
+#  include <strings.h>
+# endif
+# ifdef HAVE_LIMITS_H
+#  include <limits.h>
+# endif
 #else
-# include <strings.h>
-#endif
-#ifdef HAVE_LIMITS_H
+/* If running without Autoconf, go ahead and assume presence of
+   standard C89 headers.  */
+# include <string.h>
 # include <limits.h>
 #endif
+
 #include <stdlib.h>
 #include <assert.h>
 
-#include "wget.h"
-#include "utils.h"
-
-#include "hash.h"
-
-#ifdef STANDALONE
-# undef xmalloc
-# undef xrealloc
-# undef xfree
-
-# define xmalloc malloc
-# define xrealloc realloc
+#ifndef STANDALONE
+/* Get Wget's utility headers. */
+# include "wget.h"
+# include "utils.h"
+#else
+/* Make do without them. */
+# define xnew(x) xmalloc (sizeof (x))
+# define xnew_array(type, x) xmalloc (sizeof (type) * (x))
+# define xmalloc malloc                /* or something that exits
+                                  if not enough memory */
 # define xfree free
-
-# undef TOLOWER
+# define countof(x) (sizeof (x) / sizeof ((x)[0]))
 # define TOLOWER(x) ('A' <= (x) && (x) <= 'Z' ? (x) - 32 : (x))
+# define PARAMS(x) x
 #endif
 
+#include "hash.h"
+
 /* INTERFACE:
 
    Hash tables are a technique used to implement mapping between
@@ -286,6 +294,7 @@ hash_table_new (int items,
   /*assert (ht->resize_threshold >= items);*/
 
   ht->mappings = xnew_array (struct mapping, ht->size);
+
   /* Mark mappings as empty.  We use 0xff rather than 0 to mark empty
      keys because it allows us to use NULL/0 as keys.  */
   memset (ht->mappings, INVALID_PTR_BYTE, size * sizeof (struct mapping));
@@ -692,7 +701,7 @@ ptrcmp (const void *ptr1, const void *ptr2)
   return ptr1 == ptr2;
 }
 \f
-#ifdef STANDALONE
+#ifdef TEST
 
 #include <stdio.h>
 #include <string.h>
@@ -746,4 +755,4 @@ main (void)
 #endif
   return 0;
 }
-#endif
+#endif /* TEST */