-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOneRelease.cpp
More file actions
executable file
·71 lines (64 loc) · 1.09 KB
/
OneRelease.cpp
File metadata and controls
executable file
·71 lines (64 loc) · 1.09 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* OneRelease.cpp
*
* Created on: 31 Oct 2013
* Author: lester
*/
#include "OneRelease.h"
#include "log.h"
OneRelease::OneRelease()
{
first = 0;
}
void OneRelease::release()
{
if (first != 0)
{
first->release();
first = 0;
}
#ifdef _TEST
log_e(",mem,0");
#endif
}
// store a string
void OneRelease::alloc(const char *str, unsigned int len, char * &new_str)
{
LinearAlloc **allocator = &first;
for (;;)
{
if (*allocator == 0)
{
*allocator = LinearAlloc::create(len + 1);
break;
}
if ((*allocator)->getFree() >= (len + 1))
break;
allocator = (*allocator)->getnext();
}
(*allocator)->AddString(str, len, new_str);
}
/*
* reading file more than 65KB it does not work
*/
void* OneRelease::alloc(unsigned int size)
{
#ifdef _TEST
static unsigned int tot = 0;
tot += size;
log_e(",mem,%d", tot);
#endif
LinearAlloc **allocator = &first;
for (;;)
{
if (*allocator == 0)
{
*allocator = LinearAlloc::create(size);
break;
}
if ((*allocator)->getFree() >= size)
break;
allocator = (*allocator)->getnext();
}
return (*allocator)->get(size);
}