recycle.c

recycle.c · 502 B

From the archive event-queue.zip

Download the archive   « Back to the archive contents

/** Add this after the include files **/

EVENT_DATA *ev_free;

EVENT_DATA *new_event(void)
{
	static EVENT_DATA ev_zero;
	EVENT_DATA *ev;

    if (ev_free == NULL)
		ev = alloc_perm(sizeof(*ev));
    else
    {
		ev = ev_free;
		ev_free = ev_free->next;
    }

    *ev = ev_zero;
    VALIDATE(ev);
    ev->to   = NULL;
    return ev;
}

void free_event(EVENT_DATA *ev)
{
    if (!IS_VALID(ev))
		return;
	
	INVALIDATE(ev);

    ev->next = ev_free;
    ev_free = ev;
}

Site Stats

Snippets: 1791
Codebases: 571