Give each paste buffer a size member instead of requiring them to be

zero-terminated.
This commit is contained in:
Nicholas Marriott
2009-09-07 18:50:45 +00:00
parent e97006b102
commit ccba613e5b
11 changed files with 62 additions and 47 deletions

View File

@ -97,7 +97,7 @@ paste_free_index(struct paste_stack *ps, u_int idx)
}
void
paste_add(struct paste_stack *ps, char *data, u_int limit)
paste_add(struct paste_stack *ps, u_char *data, size_t size, u_int limit)
{
struct paste_buffer *pb;
@ -115,12 +115,13 @@ paste_add(struct paste_stack *ps, char *data, u_int limit)
ARRAY_INSERT(ps, 0, pb);
pb->data = data;
pb->size = size;
if (gettimeofday(&pb->tv, NULL) != 0)
fatal("gettimeofday");
}
int
paste_replace(struct paste_stack *ps, u_int idx, char *data)
paste_replace(struct paste_stack *ps, u_int idx, u_char *data, size_t size)
{
struct paste_buffer *pb;
@ -131,6 +132,7 @@ paste_replace(struct paste_stack *ps, u_int idx, char *data)
xfree(pb->data);
pb->data = data;
pb->size = size;
if (gettimeofday(&pb->tv, NULL) != 0)
fatal("gettimeofday");