Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=1d532b414b2a9c57dc4fa70b62584e07caa7a0d2
commit 1d532b414b2a9c57dc4fa70b62584e07caa7a0d2 Author: James Buren <[email protected]> Date: Sat Aug 11 17:51:55 2012 -0500 add linked list function diff --git a/fwsetup.h b/fwsetup.h index 2d03797..ead79cd 100644 --- a/fwsetup.h +++ b/fwsetup.h @@ -59,6 +59,7 @@ struct module }; extern void eprintf(const char *s,...) __attribute__((format(printf,1,2)));; +extern void *list_append(void *list,size_t n); extern int main(void); extern struct module begin_module; extern struct module partition_setup_module; diff --git a/utility.c b/utility.c index 22e9c33..2eb8359 100644 --- a/utility.c +++ b/utility.c @@ -1,5 +1,11 @@ #include "fwsetup.h" +struct list +{ + struct list *prev; + struct list *next; +}; + static FILE *redirect_std_stream(FILE *oldfp,int oldfd) { assert(oldfp != 0); @@ -51,6 +57,31 @@ extern void eprintf(const char *s,...) va_end(args); } +extern void *list_append(void *list,size_t n) +{ + assert(n > sizeof(struct list)); + + struct list *a = list; + struct list *b = malloc(n); + + if(a == 0) + { + b->prev = 0; + + b->next = 0; + } + else + { + a->next = b; + + b->prev = a; + + b->next = 0; + } + + return b; +} + #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
