LList fix
This commit is contained in:
parent
f2ce18b16d
commit
b557881168
@ -32,8 +32,8 @@ typedef struct LList(T) { \
|
|||||||
} LList(T); \
|
} LList(T); \
|
||||||
\
|
\
|
||||||
/* Peek node from list. Detatched nodes can be inserted in different place. */ \
|
/* Peek node from list. Detatched nodes can be inserted in different place. */ \
|
||||||
static inline LLNode(T)* LList_##T##_detatch(LList(T)* l, LLNode(T)* n) \
|
static inline void LList_##T##_detatch(LList(T)* l, LLNode(T)* n) \
|
||||||
{ return _LList_detatch((void*)l, (void*)n); } \
|
{ _LList_detatch((void*)l, (void*)n); } \
|
||||||
\
|
\
|
||||||
/* @param detatched must have null .next and .prev */ \
|
/* @param detatched must have null .next and .prev */ \
|
||||||
/* @param target can be null only if it is l->first or l->last */ \
|
/* @param target can be null only if it is l->first or l->last */ \
|
||||||
@ -80,7 +80,7 @@ typedef struct LList_ {
|
|||||||
} LList_;
|
} LList_;
|
||||||
|
|
||||||
/* Peek node from list. Detatched nodes can be inserted in different place. */
|
/* Peek node from list. Detatched nodes can be inserted in different place. */
|
||||||
LLNode_* _LList_detatch(LList_* l, LLNode_* n);
|
void _LList_detatch(LList_* l, LLNode_* n);
|
||||||
|
|
||||||
/* @param detatched must have null .next and .prev */
|
/* @param detatched must have null .next and .prev */
|
||||||
/* @param target can be null only if it is l->first or l->last */
|
/* @param target can be null only if it is l->first or l->last */
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "tlibc/collections/LList.h"
|
#include "tlibc/collections/LList.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
LLNode_* _LList_detatch(LList_* l, LLNode_* n){
|
void _LList_detatch(LList_* l, LLNode_* n){
|
||||||
if(n == l->first){
|
if(n == l->first){
|
||||||
l->first = n->next;
|
l->first = n->next;
|
||||||
}
|
}
|
||||||
@ -20,7 +21,6 @@ LLNode_* _LList_detatch(LList_* l, LLNode_* n){
|
|||||||
l->count--;
|
l->count--;
|
||||||
n->prev = NULL;
|
n->prev = NULL;
|
||||||
n->next = NULL;
|
n->next = NULL;
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _LList_insertAfter(LList_* l, NULLABLE(LLNode_*) target, LLNode_* detatched)
|
void _LList_insertAfter(LList_* l, NULLABLE(LLNode_*) target, LLNode_* detatched)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user