Example #1
0
void *v_pstr (Vector vec, char *data)
{
	if (vec->len >= vec->mlen)
	{
		vec->mlen = V_NEXT_LENGTH(vec->mlen);
		vec->data = realloc (vec->data, vec->mlen * vec->siz);
	}
	memcpy (DATA(vec->len), data, strlen (data) + 1);
	++ vec->len;
	return v_at (vec, vec->len - 1);
}
Example #2
0
void *v_push (Vector vec, void *data)
{
	if (vec->data == NULL)
		panic("NULL vector");
	if (vec->len >= vec->mlen)
	{
		vec->mlen = V_NEXT_LENGTH(vec->mlen);
		vec->data = realloc (vec->data, vec->mlen * vec->siz);
	}
	memcpy (DATA(vec->len), data, vec->siz);
	++ vec->len;
	return v_at (vec, vec->len - 1);
}
Example #3
0
void t_flush ()
{
	if (times == NULL)
		return;
	int i;
	for (i = 0; i < times->len; ++ i)
	{
		struct Timer *t = v_at (times, i);
		if ((t->flags & TMR_STOP) == 0)
			continue;
		t->callback (t->arg);
		v_rem (times, i);
		-- i;
	}
}
Example #4
0
void t_idle ()
{
	if (times == NULL)
		return;
	int i, current = SDL_GetTicks ();
	for (i = 0; i < times->len; ++ i)
	{
		struct Timer *t = v_at (times, i);
		if (t->time >= current)
			continue;
		t->callback (t->arg);
		v_rem (times, i);
		-- i;
	}
}