diff options
Diffstat (limited to 'src/memory.c')
-rw-r--r-- | src/memory.c | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/memory.c b/src/memory.c deleted file mode 100644 index ca7e6f51..00000000 --- a/src/memory.c +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | /* Copyrights 2002 Luis Figueiredo (stdio@netc.pt) All rights reserved. | ||
2 | * | ||
3 | * See the LICENSE file | ||
4 | * | ||
5 | * The origin of this software must not be misrepresented, either by | ||
6 | * explicit claim or by omission. Since few users ever read sources, | ||
7 | * credits must appear in the documentation. | ||
8 | * | ||
9 | * date: Sat Mar 30 14:25:25 GMT 2002 | ||
10 | * | ||
11 | * -- memory functions | ||
12 | */ | ||
13 | #include "memory.h" | ||
14 | |||
15 | struct memrequest { | ||
16 | char *ptr; | ||
17 | struct memrequest *next; | ||
18 | }; | ||
19 | |||
20 | /* | ||
21 | * Add a buffer to memrequest list | ||
22 | */ | ||
23 | void *__ILWS_add_buffer(struct memrequest *list,unsigned int size) { | ||
24 | struct memrequest *tmem; | ||
25 | if(size==0) { | ||
26 | return NULL; | ||
27 | }; | ||
28 | if(list!=NULL) { | ||
29 | tmem=list; | ||
30 | }else { | ||
31 | return NULL; | ||
32 | }; | ||
33 | while(tmem->next!=NULL)tmem=tmem->next; | ||
34 | tmem->next=__ILWS_malloc(sizeof(struct memrequest)); | ||
35 | if(tmem->next==NULL) return NULL; // ERROR | ||
36 | tmem->next->ptr=__ILWS_malloc(size); | ||
37 | tmem->next->next=NULL; | ||
38 | return tmem->next->ptr; | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * Initialize memrequest list of buffers | ||
43 | */ | ||
44 | struct memrequest *__ILWS_init_buffer_list() { | ||
45 | struct memrequest *newlist; | ||
46 | newlist=__ILWS_malloc(sizeof(struct memrequest)); | ||
47 | if(newlist==NULL) | ||
48 | return NULL; | ||
49 | newlist->next=NULL; | ||
50 | newlist->ptr=NULL; | ||
51 | return newlist; | ||
52 | } | ||
53 | |||
54 | /* | ||
55 | * Delete memrequest buffer node (free) | ||
56 | */ | ||
57 | void __ILWS_delete_buffer(struct memrequest *mem) { | ||
58 | __ILWS_free(mem->ptr); | ||
59 | __ILWS_free(mem); | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * Delete memrequest next buffer | ||
64 | */ | ||
65 | void __ILWS_delete_next_buffer(struct memrequest *mem) { | ||
66 | struct memrequest *tmem; | ||
67 | tmem=mem->next; | ||
68 | mem->next=mem->next->next; | ||
69 | __ILWS_delete_buffer(tmem); | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * Delete whole memrequest buffer list | ||
74 | */ | ||
75 | void __ILWS_delete_buffer_list(struct memrequest *list) { | ||
76 | struct memrequest *tmem=list; | ||
77 | if (tmem==NULL) | ||
78 | return; | ||
79 | |||
80 | while(tmem->next!=NULL) { | ||
81 | __ILWS_delete_next_buffer(tmem); | ||
82 | }; | ||
83 | __ILWS_delete_buffer(tmem); | ||
84 | } | ||
85 | |||