Add new ply_buffer_remove_bytes_at_end

This function is like ply_buffer_remove_bytes, but it
truncates away the end of the buffer instead of shifting
the contents over the start of the buffer.
calculate-0.9.5
Ray Strode 16 years ago
parent 21081183a2
commit d2b4a3ef73

@ -85,6 +85,17 @@ ply_buffer_remove_bytes (ply_buffer_t *buffer,
}
}
void
ply_buffer_remove_bytes_at_end (ply_buffer_t *buffer,
size_t bytes_to_remove)
{
assert (buffer != NULL);
bytes_to_remove = MIN (buffer->size, bytes_to_remove);
buffer->size -= bytes_to_remove;
}
ply_buffer_t *
ply_buffer_new (void)
{

@ -45,6 +45,8 @@ void ply_buffer_append_with_non_literal_format_string (ply_buffer_t *buffer,
const char *format, ...);
void ply_buffer_remove_bytes (ply_buffer_t *buffer,
size_t number_of_bytes);
void ply_buffer_remove_bytes_at_end (ply_buffer_t *buffer,
size_t number_of_bytes);
const char *ply_buffer_get_bytes (ply_buffer_t *buffer);
size_t ply_buffer_get_size (ply_buffer_t *buffer);
void ply_buffer_clear (ply_buffer_t *buffer);

Loading…
Cancel
Save