X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fhmap.c;h=4436f8dfca1375f89ced27f907a2cdeeb2b52111;hb=81579d9e9f994fb2908f50af41c3eb033d216e58;hp=4c97e2359c922034cc8389344dc2a581227042d7;hpb=8ef8acb7c70a321963d30f2264e8f91e16427fcf;p=pspp-builds.git diff --git a/src/libpspp/hmap.c b/src/libpspp/hmap.c index 4c97e235..4436f8df 100644 --- a/src/libpspp/hmap.c +++ b/src/libpspp/hmap.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,11 +18,12 @@ #include #endif -#include +#include "libpspp/hmap.h" + #include #include -#include "xalloc.h" +#include "gl/xalloc.h" static size_t capacity_to_mask (size_t capacity); @@ -49,6 +50,18 @@ hmap_swap (struct hmap *a, struct hmap *b) b->buckets = &b->one; } +/* Removes all of the elements from MAP, without destroying MAP itself and + without accessing the existing elements (if any). */ +void +hmap_clear (struct hmap *map) +{ + size_t i; + + for (i = 0; i <= map->mask; i++) + map->buckets[i] = NULL; + map->count = 0; +} + /* Frees the memory, if any, allocated by hash map MAP. This has no effect on the actual data items in MAP, if any, because the client is responsible for allocating and freeing them. It