summaryrefslogtreecommitdiff
path: root/settings.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-02-01 17:48:20 +0000
committertruelight <truelight@openttd.org>2005-02-01 17:48:20 +0000
commitc02c35e256df49c88bb654f707379f803d70a120 (patch)
tree12eb860d17a6f01adfbf1f39398983ca3e379149 /settings.c
parent20d1f357dd058a726a1424b25d62e1c445bd74f8 (diff)
downloadopenttd-c02c35e256df49c88bb654f707379f803d70a120.tar.xz
(svn r1762) -Codechange: renamed 'MemoryPool' to 'SettingsMemoryPool' (we need
MemoryPool for general-dynamic-arrays)
Diffstat (limited to 'settings.c')
-rw-r--r--settings.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/settings.c b/settings.c
index f67090732..ae7f9874e 100644
--- a/settings.c
+++ b/settings.c
@@ -8,40 +8,40 @@
typedef struct IniFile IniFile;
typedef struct IniItem IniItem;
typedef struct IniGroup IniGroup;
-typedef struct MemoryPool MemoryPool;
+typedef struct SettingsMemoryPool SettingsMemoryPool;
-static void pool_init(MemoryPool **pool);
-static void *pool_alloc(MemoryPool **pool, uint size);
-static void *pool_strdup(MemoryPool **pool, const char *mem, uint size);
-static void pool_free(MemoryPool **pool);
+static void pool_init(SettingsMemoryPool **pool);
+static void *pool_alloc(SettingsMemoryPool **pool, uint size);
+static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size);
+static void pool_free(SettingsMemoryPool **pool);
-struct MemoryPool {
+struct SettingsMemoryPool {
uint pos,size;
- MemoryPool *next;
+ SettingsMemoryPool *next;
byte mem[1];
};
-static MemoryPool *pool_new(uint minsize)
+static SettingsMemoryPool *pool_new(uint minsize)
{
- MemoryPool *p;
+ SettingsMemoryPool *p;
if (minsize < 4096 - 12) minsize = 4096 - 12;
- p = malloc(sizeof(MemoryPool) - 1 + minsize);
+ p = malloc(sizeof(SettingsMemoryPool) - 1 + minsize);
p->pos = 0;
p->size = minsize;
p->next = NULL;
return p;
}
-static void pool_init(MemoryPool **pool)
+static void pool_init(SettingsMemoryPool **pool)
{
*pool = pool_new(0);
}
-static void *pool_alloc(MemoryPool **pool, uint size)
+static void *pool_alloc(SettingsMemoryPool **pool, uint size)
{
uint pos;
- MemoryPool *p = *pool;
+ SettingsMemoryPool *p = *pool;
size = (size + 3) & ~3; // align everything to a 32 bit boundary
@@ -50,7 +50,7 @@ static void *pool_alloc(MemoryPool **pool, uint size)
p = p->next;
// then check if there's not memory in the cur pool
} else if (p->pos + size > p->size) {
- MemoryPool *n = pool_new(size);
+ SettingsMemoryPool *n = pool_new(size);
*pool = n;
n->next = p;
p = n;
@@ -61,7 +61,7 @@ static void *pool_alloc(MemoryPool **pool, uint size)
return p->mem + pos;
}
-static void *pool_strdup(MemoryPool **pool, const char *mem, uint size)
+static void *pool_strdup(SettingsMemoryPool **pool, const char *mem, uint size)
{
byte *p = pool_alloc(pool, size + 1);
p[size] = 0;
@@ -69,9 +69,9 @@ static void *pool_strdup(MemoryPool **pool, const char *mem, uint size)
return p;
}
-static void pool_free(MemoryPool **pool)
+static void pool_free(SettingsMemoryPool **pool)
{
- MemoryPool *p = *pool, *n;
+ SettingsMemoryPool *p = *pool, *n;
*pool = NULL;
while (p) {
n = p->next;
@@ -98,7 +98,7 @@ struct IniGroup {
};
struct IniFile {
- MemoryPool *pool;
+ SettingsMemoryPool *pool;
IniGroup *group, **last_group;
char *comment; // last comment in file
};
@@ -107,7 +107,7 @@ struct IniFile {
static IniFile *ini_alloc(void)
{
IniFile *ini;
- MemoryPool *pool;
+ SettingsMemoryPool *pool;
pool_init(&pool);
ini = (IniFile*)pool_alloc(&pool, sizeof(IniFile));
ini->pool = pool;