X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fllx.c;h=905850bc41c13ec74be83289e0571c0972f464dc;hb=88160345d1b718d5d4f7894bcd7139fd0bc1b404;hp=c58f840c40a6db106d250e0cb6b5a9dec39efa5f;hpb=02b539a8876795a0fb9cb747e297eb825a2b2747;p=pspp-builds.git diff --git a/src/libpspp/llx.c b/src/libpspp/llx.c index c58f840c..905850bc 100644 --- a/src/libpspp/llx.c +++ b/src/libpspp/llx.c @@ -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. */