mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Make hash.c compilable outside the source tree.
This commit is contained in:
parent
9a4afed6fd
commit
91ebe986e4
@ -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>
|
2004-01-29 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* utils.c (determine_screen_width): Return 0 if not running on
|
* utils.c (determine_screen_width): Return 0 if not running on
|
||||||
|
59
src/hash.c
59
src/hash.c
@ -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
|
file, but you are not obligated to do so. If you do not wish to do
|
||||||
so, delete this exception statement from your version. */
|
so, delete this exception statement from your version. */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
/* With -DSTANDALONE, this file can be compiled outside Wget source
|
||||||
# include <config.h>
|
tree. To test, also use -DTEST. */
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifndef STANDALONE
|
||||||
# include <string.h>
|
# include <config.h>
|
||||||
|
# ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
# else
|
||||||
|
# include <strings.h>
|
||||||
|
# endif
|
||||||
|
# ifdef HAVE_LIMITS_H
|
||||||
|
# include <limits.h>
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
# include <strings.h>
|
/* If running without Autoconf, go ahead and assume presence of
|
||||||
#endif
|
standard C89 headers. */
|
||||||
#ifdef HAVE_LIMITS_H
|
# include <string.h>
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "wget.h"
|
#ifndef STANDALONE
|
||||||
#include "utils.h"
|
/* 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
|
||||||
|
# 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"
|
#include "hash.h"
|
||||||
|
|
||||||
#ifdef STANDALONE
|
|
||||||
# undef xmalloc
|
|
||||||
# undef xrealloc
|
|
||||||
# undef xfree
|
|
||||||
|
|
||||||
# define xmalloc malloc
|
|
||||||
# define xrealloc realloc
|
|
||||||
# define xfree free
|
|
||||||
|
|
||||||
# undef TOLOWER
|
|
||||||
# define TOLOWER(x) ('A' <= (x) && (x) <= 'Z' ? (x) - 32 : (x))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* INTERFACE:
|
/* INTERFACE:
|
||||||
|
|
||||||
Hash tables are a technique used to implement mapping between
|
Hash tables are a technique used to implement mapping between
|
||||||
@ -286,6 +294,7 @@ hash_table_new (int items,
|
|||||||
/*assert (ht->resize_threshold >= items);*/
|
/*assert (ht->resize_threshold >= items);*/
|
||||||
|
|
||||||
ht->mappings = xnew_array (struct mapping, ht->size);
|
ht->mappings = xnew_array (struct mapping, ht->size);
|
||||||
|
|
||||||
/* Mark mappings as empty. We use 0xff rather than 0 to mark empty
|
/* Mark mappings as empty. We use 0xff rather than 0 to mark empty
|
||||||
keys because it allows us to use NULL/0 as keys. */
|
keys because it allows us to use NULL/0 as keys. */
|
||||||
memset (ht->mappings, INVALID_PTR_BYTE, size * sizeof (struct mapping));
|
memset (ht->mappings, INVALID_PTR_BYTE, size * sizeof (struct mapping));
|
||||||
@ -692,7 +701,7 @@ ptrcmp (const void *ptr1, const void *ptr2)
|
|||||||
return ptr1 == ptr2;
|
return ptr1 == ptr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STANDALONE
|
#ifdef TEST
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -746,4 +755,4 @@ main (void)
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* TEST */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user