1 | #include "salloc.h" |
1 | #include "salloc.h" |
2 | |
2 | |
3 | #define SALLOC_BLOCK 65536 // size of basic block to allocate |
3 | #define SALLOC_BLOCK 65536 // size of basic block to allocate |
4 | |
4 | |
5 | rxvt_salloc::rxvt_salloc (int size) |
5 | rxvt_salloc::rxvt_salloc (unsigned int size) |
6 | { |
6 | { |
7 | this->size = size < sizeof (chain) ? sizeof (chain) : size; |
7 | this->size = size < sizeof (chain) ? sizeof (chain) : size; |
8 | firstline = 0; |
8 | firstline = 0; |
9 | firstblock = 0; |
9 | firstblock = 0; |
10 | firstfree = SALLOC_BLOCK; |
10 | firstfree = SALLOC_BLOCK; |
… | |
… | |
38 | next->next = firstblock; |
38 | next->next = firstblock; |
39 | firstblock = next; |
39 | firstblock = next; |
40 | firstfree = sizeof (chain); |
40 | firstfree = sizeof (chain); |
41 | } |
41 | } |
42 | |
42 | |
43 | r = (void *)((char *)firstblock + firstfree); |
43 | r = (void *) ((char *)firstblock + firstfree); |
44 | |
44 | |
45 | firstfree += size; |
45 | firstfree += size; |
46 | } |
46 | } |
47 | |
47 | |
48 | return r; |
48 | return r; |
49 | } |
49 | } |
50 | |
50 | |
51 | void |
51 | void |
52 | rxvt_salloc::free (void *data) |
52 | rxvt_salloc::free (void *data) |
53 | { |
53 | { |
54 | return;//D |
|
|
55 | chain *line = (chain *)data; |
54 | chain *line = (chain *)data; |
56 | line->next = firstline; |
55 | line->next = firstline; |
57 | firstline = line; |
56 | firstline = line; |
58 | } |
57 | } |
59 | |
58 | |