X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fhmapx.c;h=ca5900c2829c85e10b2647d552141c0a1b69e809;hb=8e98d2ec1b1620280d66820e323d82b00975374e;hp=437b2bdba5a7aad4ad301f672fc3681b5f2010fd;hpb=5043ca7450640f23c1a5957c967f377f0fbefa19;p=pspp diff --git a/src/libpspp/hmapx.c b/src/libpspp/hmapx.c index 437b2bdba5..ca5900c282 100644 --- a/src/libpspp/hmapx.c +++ b/src/libpspp/hmapx.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010, 2012 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,9 +18,9 @@ #include #endif -#include +#include "libpspp/hmapx.h" #include -#include "xalloc.h" +#include "gl/xalloc.h" /* Frees the memory, if any, allocated by hash map MAP, including all hmapx_nodes that it contains. The user-defined data items @@ -45,6 +45,20 @@ hmapx_destroy (struct hmapx *map) } } +/* Removes all hmapx_nodes from MAP and frees them. The user-defined data + items that the hmapx_nodes point to are not affected. */ +void +hmapx_clear (struct hmapx *map) +{ + struct hmapx_node *node, *next; + + for (node = hmapx_first (map); node; node = next) + { + next = hmapx_next (map, node); + hmapx_delete (map, node); + } +} + /* Allocates and returns a new hmapx_node with DATA as its data item. */ static struct hmapx_node *