From e61dd7c534ed8b19ab93827001053609a218bc33 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 24 Jan 2017 11:47:35 +0100 Subject: [PATCH] isl_*_list_get_*: extract out isl_*_list_peek This function will be reused in the next commit. Signed-off-by: Sven Verdoolaege --- isl_list_templ.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/isl_list_templ.c b/isl_list_templ.c index b9b582ed..b6bd89a3 100644 --- a/isl_list_templ.c +++ b/isl_list_templ.c @@ -251,11 +251,20 @@ int FN(FN(LIST(EL),n),BASE)(__isl_keep LIST(EL) *list) return list ? list->n : 0; } -__isl_give EL *FN(FN(LIST(EL),get),BASE)(__isl_keep LIST(EL) *list, int index) +/* Return the element at position "index" in "list". + */ +static __isl_keep EL *FN(LIST(EL),peek)(__isl_keep LIST(EL) *list, int index) { if (FN(LIST(EL),check_index)(list, index) < 0) return NULL; - return FN(EL,copy)(list->p[index]); + return list->p[index]; +} + +/* Return a copy of the element at position "index" in "list". + */ +__isl_give EL *FN(FN(LIST(EL),get),BASE)(__isl_keep LIST(EL) *list, int index) +{ + return FN(EL,copy)(FN(LIST(EL),peek)(list, index)); } /* Replace the element at position "index" in "list" by "el". -- 2.11.4.GIT