2015-09-12 12:33:25 +02:00
|
|
|
#include <platform.h>
|
2015-09-12 12:24:10 +02:00
|
|
|
#include "prefix.h"
|
|
|
|
|
2015-09-12 12:49:12 +02:00
|
|
|
#include <assert.h>
|
2015-09-12 12:24:10 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
char **race_prefixes = NULL;
|
2015-09-12 12:49:12 +02:00
|
|
|
static size_t size = 4;
|
|
|
|
static unsigned int next = 0;
|
2015-09-12 12:24:10 +02:00
|
|
|
|
|
|
|
void add_raceprefix(const char *prefix)
|
|
|
|
{
|
2015-09-12 12:49:12 +02:00
|
|
|
assert(prefix);
|
|
|
|
if (race_prefixes == NULL) {
|
|
|
|
next = 0;
|
|
|
|
size = 4;
|
2015-09-12 12:24:10 +02:00
|
|
|
race_prefixes = malloc(size * sizeof(char *));
|
2015-09-12 12:49:12 +02:00
|
|
|
}
|
2015-09-12 12:24:10 +02:00
|
|
|
if (next + 1 == size) {
|
|
|
|
size *= 2;
|
|
|
|
race_prefixes = realloc(race_prefixes, size * sizeof(char *));
|
|
|
|
}
|
|
|
|
race_prefixes[next++] = _strdup(prefix);
|
|
|
|
race_prefixes[next] = NULL;
|
|
|
|
}
|
2015-09-12 12:29:42 +02:00
|
|
|
|
|
|
|
void free_prefixes(void) {
|
|
|
|
int i;
|
|
|
|
if (race_prefixes) {
|
|
|
|
for (i = 0; race_prefixes[i]; ++i) {
|
|
|
|
free(race_prefixes[i]);
|
|
|
|
}
|
|
|
|
free(race_prefixes);
|
|
|
|
race_prefixes = 0;
|
|
|
|
}
|
|
|
|
}
|