[util] Add a function to reverse delete cbuf stacks
I'm not 100% sure this is the best fix for the issue, but the way the cbuf interpreter stack works (especially in the console code) meant that the stack was built in the order opposite to how it could be safely deleted with the existing function. Yeah, more leaks :P
This commit is contained in:
parent
340127fff2
commit
b84bf16cab
|
@ -92,6 +92,7 @@ cbuf_t * Cbuf_New (cbuf_interpreter_t *interp);
|
||||||
|
|
||||||
void Cbuf_Delete (cbuf_t *cbuf);
|
void Cbuf_Delete (cbuf_t *cbuf);
|
||||||
void Cbuf_DeleteStack (cbuf_t *stack);
|
void Cbuf_DeleteStack (cbuf_t *stack);
|
||||||
|
void Cbuf_DeleteStackReverse (cbuf_t *stack);
|
||||||
void Cbuf_Reset (cbuf_t *cbuf);
|
void Cbuf_Reset (cbuf_t *cbuf);
|
||||||
cbuf_t *Cbuf_PushStack (cbuf_interpreter_t *interp);
|
cbuf_t *Cbuf_PushStack (cbuf_interpreter_t *interp);
|
||||||
void Cbuf_AddText (cbuf_t *cbuf, const char *text);
|
void Cbuf_AddText (cbuf_t *cbuf, const char *text);
|
||||||
|
|
|
@ -123,6 +123,17 @@ Cbuf_DeleteStack (cbuf_t *stack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
Cbuf_DeleteStackReverse (cbuf_t *stack)
|
||||||
|
{
|
||||||
|
cbuf_t *next;
|
||||||
|
|
||||||
|
for (; stack; stack = next) {
|
||||||
|
next = stack->up;
|
||||||
|
Cbuf_Delete (stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cbuf_Reset (cbuf_t *cbuf)
|
Cbuf_Reset (cbuf_t *cbuf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -486,7 +486,7 @@ main (int argc, char **argv)
|
||||||
free (thread_data.a[i]);
|
free (thread_data.a[i]);
|
||||||
}
|
}
|
||||||
DARRAY_CLEAR (&thread_data);
|
DARRAY_CLEAR (&thread_data);
|
||||||
Cbuf_Delete (qwaq_cbuf);
|
Cbuf_DeleteStackReverse (qwaq_cbuf);
|
||||||
Sys_Shutdown ();
|
Sys_Shutdown ();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue