Example #1
0
void
paste_add(struct paste_stack *ps, char *data, u_int limit)
{
	struct paste_buffer	*pb;

	while (ARRAY_LENGTH(ps) >= limit)
		ARRAY_TRUNC(ps, 1);

	pb = xmalloc(sizeof *pb);
	ARRAY_INSERT(ps, 0, pb);

	pb->data = data;
	if (gettimeofday(&pb->tv, NULL) != 0)
		fatal("gettimeofday");
}
Example #2
0
/*
 * Add an item onto the top of the stack, freeing the bottom if at limit. Note
 * that the caller is responsible for allocating data.
 */
void
paste_add(struct paste_stack *ps, char *data, size_t size, u_int limit)
{
	struct paste_buffer	*pb;

	if (size == 0)
		return;

	while (ARRAY_LENGTH(ps) >= limit) {
		pb = ARRAY_LAST(ps);
		xfree(pb->data);
		xfree(pb);
		ARRAY_TRUNC(ps, 1);
	}

	pb = xmalloc(sizeof *pb);
	ARRAY_INSERT(ps, 0, pb);

	pb->data = data;
	pb->size = size;
}
Example #3
0
void
paste_add(struct paste_stack *ps, u_char *data, size_t size, u_int limit)
{
	struct paste_buffer	*pb;

	if (*data == '\0')
		return;

	while (ARRAY_LENGTH(ps) >= limit) {
		pb = ARRAY_LAST(ps);
		xfree(pb->data);
		xfree(pb);
		ARRAY_TRUNC(ps, 1);
	}

	pb = xmalloc(sizeof *pb);
	ARRAY_INSERT(ps, 0, pb);

	pb->data = data;
	pb->size = size;
	if (gettimeofday(&pb->tv, NULL) != 0)
		fatal("gettimeofday");
}