forked from github/server
opstack cleanup.
This commit is contained in:
parent
b2404889d8
commit
ddac39dcfa
|
@ -35,7 +35,8 @@ variant
|
||||||
opstack_pop(opstack ** stackp)
|
opstack_pop(opstack ** stackp)
|
||||||
{
|
{
|
||||||
opstack * stack = *stackp;
|
opstack * stack = *stackp;
|
||||||
assert(stack);
|
|
||||||
|
assert(stack);
|
||||||
assert(stack->top>stack->begin);
|
assert(stack->top>stack->begin);
|
||||||
return *(--stack->top);
|
return *(--stack->top);
|
||||||
}
|
}
|
||||||
|
@ -46,13 +47,13 @@ opstack_push(opstack ** stackp, variant data)
|
||||||
opstack * stack = *stackp;
|
opstack * stack = *stackp;
|
||||||
if (stack==NULL) {
|
if (stack==NULL) {
|
||||||
stack = (opstack*)malloc(sizeof(opstack));
|
stack = (opstack*)malloc(sizeof(opstack));
|
||||||
stack->size = 4;
|
stack->size = 1;
|
||||||
stack->begin = malloc(sizeof(variant) * stack->size);
|
stack->begin = malloc(sizeof(variant) * stack->size);
|
||||||
stack->top = stack->begin;
|
stack->top = stack->begin;
|
||||||
*stackp = stack;
|
*stackp = stack;
|
||||||
}
|
}
|
||||||
if (stack->top - stack->begin == stack->size) {
|
if (stack->top - stack->begin == stack->size) {
|
||||||
int pos = stack->top - stack->begin;
|
size_t pos = stack->top - stack->begin;
|
||||||
stack->size += stack->size;
|
stack->size += stack->size;
|
||||||
stack->begin = realloc(stack->begin, sizeof(variant) * stack->size);
|
stack->begin = realloc(stack->begin, sizeof(variant) * stack->size);
|
||||||
stack->top = stack->begin + pos;
|
stack->top = stack->begin + pos;
|
||||||
|
@ -352,7 +353,9 @@ translate(const char* format, const void * userdata, const char* vars, variant a
|
||||||
char symbol[32];
|
char symbol[32];
|
||||||
char *oc = symbol;
|
char *oc = symbol;
|
||||||
opstack * stack = NULL;
|
opstack * stack = NULL;
|
||||||
brelease();
|
const char * rv;
|
||||||
|
|
||||||
|
brelease();
|
||||||
free_variables();
|
free_variables();
|
||||||
|
|
||||||
assert(format);
|
assert(format);
|
||||||
|
@ -369,7 +372,10 @@ translate(const char* format, const void * userdata, const char* vars, variant a
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse(&stack, format, userdata)==NULL) return NULL;
|
if (parse(&stack, format, userdata)==NULL) return NULL;
|
||||||
return (const char*)opop(&stack).v;
|
rv = (const char*)opop(&stack).v;
|
||||||
|
free(stack->begin);
|
||||||
|
free(stack);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue