1*bb4544dfSespie /* $OpenBSD: lstAddNew.c,v 1.8 2010/07/19 19:46:44 espie Exp $ */
204ed836eSespie /* ex:ts=8 sw=4:
304ed836eSespie */
404ed836eSespie
504ed836eSespie /*
604ed836eSespie * Copyright (c) 1999 Marc Espie.
704ed836eSespie *
804ed836eSespie * Code written for the OpenBSD project.
904ed836eSespie *
1004ed836eSespie * Redistribution and use in source and binary forms, with or without
1104ed836eSespie * modification, are permitted provided that the following conditions
1204ed836eSespie * are met:
1304ed836eSespie * 1. Redistributions of source code must retain the above copyright
1404ed836eSespie * notice, this list of conditions and the following disclaimer.
1504ed836eSespie * 2. Redistributions in binary form must reproduce the above copyright
1604ed836eSespie * notice, this list of conditions and the following disclaimer in the
1704ed836eSespie * documentation and/or other materials provided with the distribution.
1804ed836eSespie *
1904ed836eSespie * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
2004ed836eSespie * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2104ed836eSespie * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2204ed836eSespie * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
2304ed836eSespie * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2404ed836eSespie * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2504ed836eSespie * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2604ed836eSespie * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2704ed836eSespie * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2804ed836eSespie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2904ed836eSespie * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3004ed836eSespie */
3104ed836eSespie
3204ed836eSespie #include "lstInt.h"
339d9c3e66Sespie #include <stddef.h>
3404ed836eSespie
3504ed836eSespie /* Add datum to the end of a list only if it wasn't there already.
36f7923656Sespie * Returns false if datum was already there.
3704ed836eSespie */
38f7923656Sespie bool
Lst_AddNew(Lst l,void * d)39ad2b054bSespie Lst_AddNew(Lst l, void *d)
4004ed836eSespie {
4104ed836eSespie if (Lst_Member(l, d) != NULL)
42f7923656Sespie return false;
4304ed836eSespie else {
4404ed836eSespie Lst_AtEnd(l, d);
45f7923656Sespie return true;
4604ed836eSespie }
4704ed836eSespie }
4804ed836eSespie
49