Skip to content

Commit

Permalink
Removed buffer_reset().
Browse files Browse the repository at this point in the history
It was just a wrapper to buffer_set_used_size() and its comment was a bit
confusing (or obsolete), since it wasn't actually immediately zeroing out
the buffer.
  • Loading branch information
sirainen authored and GitLab committed May 18, 2016
1 parent 94a6b3d commit f6d5c9f
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/lib-index/mail-cache-lookup.c
Expand Up @@ -313,7 +313,7 @@ static int mail_cache_seq(struct mail_cache_view *view, uint32_t seq)

if (++view->cached_exists_value == 0) {
/* wrapped, we'll have to clear the buffer */
buffer_reset(view->cached_exists_buf);
buffer_set_used_size(view->cached_exists_buf, 0);
view->cached_exists_value++;
}
view->cached_exists_seq = seq;
Expand Down
2 changes: 1 addition & 1 deletion src/lib-index/mail-index-map-read.c
Expand Up @@ -162,7 +162,7 @@ mail_index_try_read_map(struct mail_index_map *map,
pos = hdr->header_size;

/* place the base header into memory. */
buffer_reset(map->hdr_copy_buf);
buffer_set_used_size(map->hdr_copy_buf, 0);
buffer_append(map->hdr_copy_buf, buf, pos);

if (pos != hdr->header_size) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib-index/mail-index-sync-update.c
Expand Up @@ -990,7 +990,7 @@ int mail_index_sync_map(struct mail_index_map **_map,
and updates hdr_base to hdr_copy_buf. so the buffer must
initially contain a valid header or we'll break it when
writing it. */
buffer_reset(map->hdr_copy_buf);
buffer_set_used_size(map->hdr_copy_buf, 0);
buffer_append(map->hdr_copy_buf, map->hdr_base,
map->hdr.header_size);
map->hdr_base = map->hdr_copy_buf->data;
Expand Down
2 changes: 1 addition & 1 deletion src/lib-mail/istream-header-filter.c
Expand Up @@ -383,7 +383,7 @@ handle_end_body_with_lf(struct header_filter_istream *mstream, ssize_t ret)
i_assert(!mstream->last_lf_added);
i_assert(size == 0 || data[size-1] != '\n');

buffer_reset(mstream->hdr_buf);
buffer_set_used_size(mstream->hdr_buf, 0);
buffer_append(mstream->hdr_buf, data, size);
if (mstream->crlf)
buffer_append_c(mstream->hdr_buf, '\r');
Expand Down
5 changes: 0 additions & 5 deletions src/lib/buffer.c
Expand Up @@ -174,11 +174,6 @@ pool_t buffer_get_pool(const buffer_t *_buf)
return buf->pool;
}

void buffer_reset(buffer_t *buf)
{
buffer_set_used_size(buf, 0);
}

void buffer_write(buffer_t *_buf, size_t pos,
const void *data, size_t data_size)
{
Expand Down
3 changes: 0 additions & 3 deletions src/lib/buffer.h
Expand Up @@ -39,9 +39,6 @@ void *buffer_free_without_data(buffer_t **buf);
/* Returns the pool buffer was created with. */
pool_t buffer_get_pool(const buffer_t *buf) ATTR_PURE;

/* Reset the buffer. used size and it's contents are zeroed. */
void buffer_reset(buffer_t *buf);

/* Write data to buffer at specified position. */
void buffer_write(buffer_t *buf, size_t pos,
const void *data, size_t data_size);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/test-pkcs5.c
Expand Up @@ -37,7 +37,7 @@ void test_pkcs5_pbkdf2(void)
test_begin("pkcs5_pbkdf2");

for(size_t i = 0; i < N_ELEMENTS(test_vectors_v2); i++) {
buffer_reset(res);
buffer_set_used_size(res, 0);
const struct test_vector *vec = &(test_vectors_v2[i]);
pkcs5_pbkdf(PKCS5_PBKDF2, hash_method_lookup(vec->prf), vec->p, vec->pLen, vec->s, vec->sLen, vec->i, vec->dkLen, res);
test_assert_idx(memcmp(res->data, vec->dk, vec->dkLen) == 0, i);
Expand Down

0 comments on commit f6d5c9f

Please sign in to comment.