Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=9aac1918b3af3bbb270a97020cdb66d20ccf9c76
commit 9aac1918b3af3bbb270a97020cdb66d20ccf9c76 Author: James Buren <[email protected]> Date: Sat Aug 11 18:57:53 2012 -0500 add functions for finding the start and end of a linked list diff --git a/fwsetup.h b/fwsetup.h index ead79cd..7eae3bc 100644 --- a/fwsetup.h +++ b/fwsetup.h @@ -58,8 +58,17 @@ struct module enum order (*run) (struct database *); }; +struct string +{ + struct string *prev; + struct string *next; + char *data; +}; + extern void eprintf(const char *s,...) __attribute__((format(printf,1,2)));; extern void *list_append(void *list,size_t n); +extern void *list_find_start(void *list); +extern void *list_find_end(void *list); extern int main(void); extern struct module begin_module; extern struct module partition_setup_module; diff --git a/utility.c b/utility.c index 2eb8359..e9a5192 100644 --- a/utility.c +++ b/utility.c @@ -82,6 +82,30 @@ extern void *list_append(void *list,size_t n) return b; } +extern void *list_find_start(void *list) +{ + assert(list != 0); + + struct list *p = list; + + while(p->prev) + p = p->prev; + + return p; +} + +extern void *list_find_end(void *list) +{ + assert(list != 0); + + struct list *p = list; + + while(p->next) + p = p->next; + + return p; +} + #ifdef NEWT extern bool get_text_size(const char *text,int *width,int *height) { _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
