Author: cazfi Date: Wed Feb 24 15:14:25 2016 New Revision: 32067 URL: http://svn.gna.org/viewcvs/freeciv?rev=32067&view=rev Log: Inlined functions to navigate genlist
See patch #6992 Modified: branches/S2_6/utility/genlist.c branches/S2_6/utility/genlist.h Modified: branches/S2_6/utility/genlist.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/genlist.c?rev=32067&r1=32066&r2=32067&view=diff ============================================================================== --- branches/S2_6/utility/genlist.c (original) +++ branches/S2_6/utility/genlist.c Wed Feb 24 15:14:25 2016 @@ -24,13 +24,6 @@ #include "shared.h" /* array_shuffle */ #include "genlist.h" - -/* A single element of a genlist, storing the pointer to user - * data, and pointers to the next and previous elements: */ -struct genlist_link { - struct genlist_link *next, *prev; - void *dataptr; -}; /**************************************************************************** Create a new empty genlist. @@ -699,27 +692,3 @@ { fc_release_mutex(&pgenlist->mutex); } - -/**************************************************************************** - Returns the pointer of this link. -****************************************************************************/ -void *genlist_link_data(const struct genlist_link *plink) -{ - return (NULL != plink ? plink->dataptr : NULL); -} - -/**************************************************************************** - Returns the previous link. -****************************************************************************/ -struct genlist_link *genlist_link_prev(const struct genlist_link *plink) -{ - return plink->prev; -} - -/**************************************************************************** - Returns the next link. -****************************************************************************/ -struct genlist_link *genlist_link_next(const struct genlist_link *plink) -{ - return plink->next; -} Modified: branches/S2_6/utility/genlist.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/genlist.h?rev=32067&r1=32066&r2=32067&view=diff ============================================================================== --- branches/S2_6/utility/genlist.h (original) +++ branches/S2_6/utility/genlist.h Wed Feb 24 15:14:25 2016 @@ -124,12 +124,40 @@ void genlist_allocate_mutex(struct genlist *pgenlist); void genlist_release_mutex(struct genlist *pgenlist); -void *genlist_link_data(const struct genlist_link *plink); -struct genlist_link *genlist_link_prev(const struct genlist_link *plink) - fc__warn_unused_result; -struct genlist_link *genlist_link_next(const struct genlist_link *plink) - fc__warn_unused_result; +/* A single element of a genlist, storing the pointer to user + * data, and pointers to the next and previous elements: */ +struct genlist_link { + struct genlist_link *next, *prev; + void *dataptr; +}; + +/**************************************************************************** + Returns the pointer of this link. +****************************************************************************/ +static inline void *genlist_link_data(const struct genlist_link *plink) +{ + return (NULL != plink ? plink->dataptr : NULL); +} + +/**************************************************************************** + Returns the previous link. +****************************************************************************/ +fc__warn_unused_result +static inline struct genlist_link *genlist_link_prev(const struct genlist_link *plink) +{ + return plink->prev; +} + +/**************************************************************************** + Returns the next link. +****************************************************************************/ +fc__warn_unused_result +static inline struct genlist_link *genlist_link_next(const struct genlist_link *plink) +{ + return plink->next; +} + #ifdef __cplusplus } #endif /* __cplusplus */ _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits