-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglthreads.c
48 lines (42 loc) · 1.03 KB
/
glthreads.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "glthreads.h"
void glthread_node_init(gl_thread_t *glthread) {
glthread->left = NULL;
glthread->right = NULL;
}
void glthread_add_next(gl_thread_t *list, gl_thread_t *glnode) {
if(list->right == NULL) {
list->right = glnode;
glnode->left = list;
return;
}
gl_thread_t *node = list->right;
list->right = glnode;
glnode->left = list;
glnode->right = node;
node->left = glnode;
}
void remove_glthread(gl_thread_t *glnode) {
if(glnode->left == NULL) {
if (glnode->right != NULL) {
glnode->right->left = NULL;
glnode->right = NULL;
return;
}
return;
}
if (glnode->right == NULL) {
glnode->left->right = NULL;
glnode->left = NULL;
return;
}
glnode->right->left = glnode->left;
glnode->left->right = glnode->right;
glnode->left = NULL;
glnode->right = NULL;
}
/*void glthread_remove(gl_thread_t *list, gl_thread_node_t *glnode) {
gl_thread_node_t *head = list->head;
if(head == glnode)
list->head = head->right;
_remove_glthread(glnode);
}*/