From ccf510188f6baee3fb90e2a2192f24ca8c994d9d Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Thu, 29 Jan 2004 16:14:25 +0000 Subject: Fix linked lists tail (bug #951) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2090 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/linkedlists.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index 30e09a015..01067d5f0 100755 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -55,10 +55,14 @@ struct { \ #define AST_LIST_INSERT_TAIL(head, elm, type, field) do { \ struct type *curelm = (head)->first; \ - while ( curelm->field.next!=NULL ) { \ - curelm=curelm->field.next; \ + if(!curelm) { \ + AST_LIST_INSERT_HEAD(head, elm, field); \ + } else { \ + while ( curelm->field.next!=NULL ) { \ + curelm=curelm->field.next; \ + } \ + AST_LIST_INSERT_AFTER(curelm,elm,field); \ } \ - AST_LIST_INSERT_AFTER(curelm,elm,field); \ } while (0) -- cgit v1.2.3