xref: /netbsd-src/usr.bin/m4/lib/ohash_enum.c (revision 315c7490d2bf841fb2c781a53547925ddf7b7e2d)
171dafaa1Schristos /* $OpenBSD: ohash_enum.c,v 1.3 2004/06/22 20:00:16 espie Exp $ */
271dafaa1Schristos /* ex:ts=8 sw=4:
371dafaa1Schristos  */
471dafaa1Schristos 
571dafaa1Schristos /* Copyright (c) 1999, 2004 Marc Espie <espie@openbsd.org>
671dafaa1Schristos  *
771dafaa1Schristos  * Permission to use, copy, modify, and distribute this software for any
871dafaa1Schristos  * purpose with or without fee is hereby granted, provided that the above
971dafaa1Schristos  * copyright notice and this permission notice appear in all copies.
1071dafaa1Schristos  *
1171dafaa1Schristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1271dafaa1Schristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1371dafaa1Schristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1471dafaa1Schristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1571dafaa1Schristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1671dafaa1Schristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1771dafaa1Schristos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1871dafaa1Schristos  */
1971dafaa1Schristos 
2071dafaa1Schristos #include "ohash_int.h"
2171dafaa1Schristos 
2271dafaa1Schristos void *
ohash_first(struct ohash * h,unsigned int * pos)2371dafaa1Schristos ohash_first(struct ohash *h, unsigned int *pos)
2471dafaa1Schristos {
2571dafaa1Schristos 	*pos = 0;
2671dafaa1Schristos 	return ohash_next(h, pos);
2771dafaa1Schristos }
2871dafaa1Schristos 
2971dafaa1Schristos void *
ohash_next(struct ohash * h,unsigned int * pos)3071dafaa1Schristos ohash_next(struct ohash *h, unsigned int *pos)
3171dafaa1Schristos {
3271dafaa1Schristos 	for (; *pos < h->size; (*pos)++)
3371dafaa1Schristos 		if (h->t[*pos].p != DELETED && h->t[*pos].p != NULL)
34*315c7490Schristos 			return __UNCONST(h->t[(*pos)++].p);
3571dafaa1Schristos 	return NULL;
3671dafaa1Schristos }
37