terminates. */
#define check(EXPR) check_func ((EXPR), __LINE__)
-/* Prints a message about memory exhaustion and exits with a
- failure code. */
-static void
-xalloc_die (void)
-{
- printf ("virtual memory exhausted\n");
- exit (EXIT_FAILURE);
-}
-
-static void *xmalloc (size_t n) MALLOC_LIKE;
-static void *xnmalloc (size_t n, size_t m) MALLOC_LIKE;
-static void *xmemdup (const void *p, size_t n) MALLOC_LIKE;
-
-/* Allocates and returns N bytes of memory. */
-static void *
-xmalloc (size_t n)
-{
- if (n != 0)
- {
- void *p = malloc (n);
- if (p == NULL)
- xalloc_die ();
-
- return p;
- }
- else
- return NULL;
-}
-
-static void *
-xmemdup (const void *p, size_t n)
-{
- void *q = xmalloc (n);
- memcpy (q, p, n);
- return q;
-}
-
-/* Clone STRING. */
-static char *
-xstrdup (const char *string)
-{
- return xmemdup (string, strlen (string) + 1);
-}
-
-/* Allocates and returns N * M bytes of memory. */
-static void *
-xnmalloc (size_t n, size_t m)
-{
- if ((size_t) -1 / m <= n)
- xalloc_die ();
- return xmalloc (n * m);
-}
\f
/* Support routines. */
check (stringi_map_contains (map, key));
- node = stringi_map_find_node (map, key);
+ node = stringi_map_find_node (map, key, strlen (key));
check (node != NULL);
check (!utf8_strcasecmp (key, stringi_map_node_get_key (node)));
check (!strcmp (value, stringi_map_node_get_value (node)));
check (!stringi_map_contains (map, "xxx"));
check (stringi_map_find (map, "0") == NULL);
- check (stringi_map_find_node (map, "") == NULL);
+ check (stringi_map_find_node (map, "", 0) == NULL);
check (!stringi_map_delete (map, "xyz"));
if (cnt == 0)
for (i = 0; i < n; i++)
{
+ const char *key = make_key (data[i]);
const char *value = make_value (data[i]);
struct stringi_map_node *node;
char *old_value;
- node = stringi_map_find_node (map, make_key (data[i]));
+ node = stringi_map_find_node (map, key, strlen (key));
check (node != NULL);
check (!strcmp (stringi_map_node_get_value (node), value));
data[i] = (data[i] & KEY_MASK) | random_value (i, 15);