X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fllx.c;h=3a0cbf60fce154cc7c5c88e390741236ae38cc80;hb=dd165516976c8801fbf7917c78f739b64e37b204;hp=c58f840c40a6db106d250e0cb6b5a9dec39efa5f;hpb=cb586666724d5fcbdb658ce471b85484f0a7babe;p=pspp diff --git a/src/libpspp/llx.c b/src/libpspp/llx.c index c58f840c40..3a0cbf60fc 100644 --- a/src/libpspp/llx.c +++ b/src/libpspp/llx.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009, 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 @@ -28,8 +28,8 @@ #include #endif -#include -#include "compiler.h" +#include "libpspp/llx.h" +#include "libpspp/compiler.h" #include #include @@ -219,6 +219,20 @@ llx_remove_if (struct llx *r0, struct llx *r1, return count; } +/* Returns the first node in R0...R1 that has data TARGET. + Returns NULL if no node in R0...R1 equals TARGET. */ +struct llx * +llx_find (const struct llx *r0, const struct llx *r1, const void *target) +{ + const struct llx *x; + + for (x = r0; x != r1; x = llx_next (x)) + if (llx_data (x) == target) + return CONST_CAST (struct llx *, x); + + return NULL; +} + /* Returns the first node in R0...R1 that equals TARGET according to COMPARE given auxiliary data AUX. Returns R1 if no node in R0...R1 equals TARGET. */