---
name: "rlist_compare"
section: "3"
platform: "linux"
package: "libroy-dev"
version: "1.0.8-1"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/rlist_compare"
---

# rlist\_compare(3)

compare two lists for equality

## NAME

rlist\_compare - compare two lists for equality

## SYNOPSIS

\#include \<roy.h\>

typedef int (\*RListComparatorFunction) (RListEntry \**entry\_a*, RListEntry \**entry\_b*);

int rlist\_compare (RList \* *list\_1*, RList \* *list\_2*, RListComparatorFunction *comparator*);

## DESCRIPTION

This call compares two lists for equality. Comparison stops immediatly if the two lists are of different length. Otherwise, each entry pair in the two lists are passed two by two into the *comparator* function as *entry\_a* and *entry\_b*. If the comparator function returns non zero at any point the comparison stops.

The comparator function should not return -1 because -1 is reserved for unequal length lists.

## RETURN VALUE

The return of -1 indicates that *list\_1* and *list\_2* are of different lengths. If the comparitor function returns anthing other than zero (0) then the [*rlist\_compare*(3)](/rlist_compare/3.md) call returns the same value, even if that value is -1.  A return value of zero (0) indicates that the two lists are equal, anything else means they are unequal.

## ERRORS

A call to [*rlist\_compare*(3)](/rlist_compare/3.md) will never fail.

## FUNCTION

The [*rlist\_compare*(3)](/rlist_compare/3.md) api is implemented using a function.

## SEE ALSO

[*rlist*(3)](/rlist/3.md), [*rlist\_append*(3)](/rlist_append/3.md),  [*rlist\_first*(3)](/rlist_first/3.md), [*rlist\_free*(3)](/rlist_free/3.md),  [*rlist\_last*(3)](/rlist_last/3.md), [*rlist\_new*(3)](/rlist_new/3.md),  [*rlist\_next*(3)](/rlist_next/3.md), [*rlist\_nth*(3)](/rlist_nth/3.md),  [*rlist\_prepend*(3)](/rlist_prepend/3.md), [*rlist\_prev*(3)](/rlist_prev/3.md),  [*rlist\_remove*(3)](/rlist_remove/3.md), [*roy*(3)](/roy/3.md)
