forked from github/server
I hate umlaut.c, it's basically magic, and the magic doesn't work right (it leaks memory from line 158)
This commit is contained in:
parent
cd9cb24b48
commit
5f9c2e13a8
1 changed files with 4 additions and 2 deletions
|
@ -155,7 +155,7 @@ void addtoken(void ** root, const char *str, variant id)
|
||||||
next = next->nexthash;
|
next = next->nexthash;
|
||||||
if (!next) {
|
if (!next) {
|
||||||
tref *ref;
|
tref *ref;
|
||||||
tnode *node = (tnode *)calloc(1, sizeof(tnode));
|
tnode *node = (tnode *)calloc(1, sizeof(tnode)); // TODO: what is the reason for this empty node to exist?
|
||||||
|
|
||||||
if (ucs < 'a' || ucs > 'z') {
|
if (ucs < 'a' || ucs > 'z') {
|
||||||
lcs = towlower((wint_t)ucs);
|
lcs = towlower((wint_t)ucs);
|
||||||
|
@ -166,6 +166,7 @@ void addtoken(void ** root, const char *str, variant id)
|
||||||
|
|
||||||
ref = (tref *)malloc(sizeof(tref));
|
ref = (tref *)malloc(sizeof(tref));
|
||||||
ref->ucs = ucs;
|
ref->ucs = ucs;
|
||||||
|
ref->node = 0;
|
||||||
ref->node = node;
|
ref->node = node;
|
||||||
ref->nexthash = tk->next[index];
|
ref->nexthash = tk->next[index];
|
||||||
tk->next[index] = ref;
|
tk->next[index] = ref;
|
||||||
|
@ -181,7 +182,7 @@ void addtoken(void ** root, const char *str, variant id)
|
||||||
ref->ucs = lcs;
|
ref->ucs = lcs;
|
||||||
ref->node = node;
|
ref->node = node;
|
||||||
ref->nexthash = tk->next[index];
|
ref->nexthash = tk->next[index];
|
||||||
tk->next[index] = ref; // FIXME: memory leak of tk->next[index]
|
tk->next[index] = ref;
|
||||||
}
|
}
|
||||||
next = ref;
|
next = ref;
|
||||||
}
|
}
|
||||||
|
@ -216,6 +217,7 @@ void freetokens(void * root)
|
||||||
while (*refs) {
|
while (*refs) {
|
||||||
tref * ref = *refs;
|
tref * ref = *refs;
|
||||||
*refs = ref->nexthash;
|
*refs = ref->nexthash;
|
||||||
|
// free(ref->node);
|
||||||
free(ref);
|
free(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue