1*4afad3d8SPeter Avalos /* $OpenBSD: ohash_enum.c,v 1.3 2004/06/22 20:00:16 espie Exp $ */
2*4afad3d8SPeter Avalos /* ex:ts=8 sw=4:
3*4afad3d8SPeter Avalos */
4*4afad3d8SPeter Avalos
5*4afad3d8SPeter Avalos /* Copyright (c) 1999, 2004 Marc Espie <espie@openbsd.org>
6*4afad3d8SPeter Avalos *
7*4afad3d8SPeter Avalos * Permission to use, copy, modify, and distribute this software for any
8*4afad3d8SPeter Avalos * purpose with or without fee is hereby granted, provided that the above
9*4afad3d8SPeter Avalos * copyright notice and this permission notice appear in all copies.
10*4afad3d8SPeter Avalos *
11*4afad3d8SPeter Avalos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12*4afad3d8SPeter Avalos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13*4afad3d8SPeter Avalos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14*4afad3d8SPeter Avalos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15*4afad3d8SPeter Avalos * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16*4afad3d8SPeter Avalos * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17*4afad3d8SPeter Avalos * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18*4afad3d8SPeter Avalos *
19*4afad3d8SPeter Avalos * $FreeBSD: src/usr.bin/m4/lib/ohash_enum.c,v 1.2 2012/11/17 01:54:24 svnexp Exp $
20*4afad3d8SPeter Avalos */
21*4afad3d8SPeter Avalos
22*4afad3d8SPeter Avalos #include "ohash_int.h"
23*4afad3d8SPeter Avalos
24*4afad3d8SPeter Avalos void *
ohash_first(struct ohash * h,unsigned int * pos)25*4afad3d8SPeter Avalos ohash_first(struct ohash *h, unsigned int *pos)
26*4afad3d8SPeter Avalos {
27*4afad3d8SPeter Avalos *pos = 0;
28*4afad3d8SPeter Avalos return ohash_next(h, pos);
29*4afad3d8SPeter Avalos }
30*4afad3d8SPeter Avalos
31*4afad3d8SPeter Avalos void *
ohash_next(struct ohash * h,unsigned int * pos)32*4afad3d8SPeter Avalos ohash_next(struct ohash *h, unsigned int *pos)
33*4afad3d8SPeter Avalos {
34*4afad3d8SPeter Avalos for (; *pos < h->size; (*pos)++) {
35*4afad3d8SPeter Avalos if (h->t[*pos].p != DELETED && h->t[*pos].p != NULL)
36*4afad3d8SPeter Avalos return __DECONST(void *, h->t[(*pos)++].p);
37*4afad3d8SPeter Avalos }
38*4afad3d8SPeter Avalos return NULL;
39*4afad3d8SPeter Avalos }
40