Improved code style. Changed linkedlist_delete to linkedlist_unlink to make linkedlist.inc universal

git-svn-id: svn://kolibrios.org@5085 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
gtament 2014-09-02 20:15:13 +00:00
parent 10723a5892
commit 3d808905f1

View File

@ -9,40 +9,37 @@ head dd 0
linkedlist_add: linkedlist_add:
push ebx push ebx
mov ebx, [head] mov ebx, [head]
mov [head], eax mov [head], eax
mov [eax + node.next], ebx mov [eax + node.next], ebx
pop ebx pop ebx
ret ret
linkedlist_delete: linkedlist_unlink:
push ebx ecx push ebx ecx
mov ebx, eax ; eax - pointer to node for delete test eax, eax
cmp eax, [head] jz .invalid_pointer
jz .unlink_head mov ebx, eax ; eax - pointer to node for unlink
cmp eax, [head]
jz .unlink_head
.getnext: .getnext:
cmp [ebx+node.next], eax cmp [ebx+node.next], eax
jz .unlink jz .unlink
cmp [ebx+node.next], 0 cmp [ebx+node.next], 0
jz .invalid_pointer jz .invalid_pointer
mov ebx, [ebx+node.next] mov ebx, [ebx+node.next]
jmp .getnext jmp .getnext
.unlink: .unlink:
mov ecx, [eax+node.next] mov ecx, [eax+node.next]
mov [ebx+node.next], ecx mov [ebx+node.next], ecx
jmp @f jmp @f
.unlink_head: .unlink_head:
mov ebx, [eax+node.next] mov ebx, [eax+node.next]
mov [head], ebx mov [head], ebx
@@: @@:
mov ecx, eax
call Kfree
.invalid_pointer: .invalid_pointer:
pop ecx ebx pop ecx ebx
ret ret
linkedlist_isvalid: ;eax - pointer to check; returns zero if valid linkedlist_isvalid: ;eax - pointer to check; returns zero if valid
push ebx ecx push ebx ecx
@ -65,8 +62,8 @@ linkedlist_isvalid: ;eax - pointer to check; returns zero if valid
ret ret
linkedlist_gethead: linkedlist_gethead:
mov eax, [head] mov eax, [head]
ret ret
restore node restore node
restore node.next restore node.next