Menu

#4 A problem about dllist

open
nobody
None
5
2010-11-17
2010-11-17
Fei
No

I found a problem when using SGLIB_DL_LIST_ADD, the order of the element is not the reverse order I added them, so I changed SGLIB_DL_LIST_ADD_BEFORE, now it is as follow. And I can use SGLIB_DL_LIST_REVERSE to make the elements in the order I added them, do you think it is right? Thanks.

#define SGLIB_DL_LIST_ADD_BEFORE(type, place, elem, previous, next) {\
if ((place) == NULL) {\
SGLIB___DL_LIST_CREATE_SINGLETON(type, place, elem, previous, next);\
} else {\
(elem)->next = (place);\
(elem)->previous = (place)->previous;\
(place)->previous = (elem);\
if ((elem)->previous != NULL) (elem)->previous->next = (elem);\
(place) = (elem);\
}\
}

Discussion


Log in to post a comment.