dovecot-2.2: istreams: Renamed i_stream_get_buffer_space() to i_...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jun 28 03:20:55 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/d7d1f24dde34
changeset: 14693:d7d1f24dde34
user: Timo Sirainen <tss at iki.fi>
date: Thu Jun 28 01:30:50 2012 +0300
description:
istreams: Renamed i_stream_get_buffer_space() to i_stream_try_alloc()
diffstat:
src/lib-mail/istream-binary-converter.c | 4 ++--
src/lib-mail/istream-dot.c | 4 ++--
src/lib-mail/istream-nonuls.c | 2 +-
src/lib-ssl-iostream/istream-openssl.c | 2 +-
src/lib/istream-base64-encoder.c | 5 ++---
src/lib/istream-chain.c | 4 ++--
src/lib/istream-concat.c | 5 ++---
src/lib/istream-crlf.c | 2 +-
src/lib/istream-file.c | 2 +-
src/lib/istream-private.h | 4 ++--
src/lib/istream.c | 6 +++---
11 files changed, 19 insertions(+), 21 deletions(-)
diffs (191 lines):
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib-mail/istream-binary-converter.c
--- a/src/lib-mail/istream-binary-converter.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib-mail/istream-binary-converter.c Thu Jun 28 01:30:50 2012 +0300
@@ -36,14 +36,14 @@
struct istream_private *stream = &bstream->istream;
size_t old_size, avail_size;
- i_stream_get_buffer_space(stream, size, &avail_size);
+ i_stream_try_alloc(stream, size, &avail_size);
if (avail_size < size) {
old_size = stream->buffer_size;
stream->buffer_size = nearest_power(stream->pos + size);
stream->w_buffer = i_realloc(stream->w_buffer, old_size,
stream->buffer_size);
stream->buffer = stream->w_buffer;
- i_stream_get_buffer_space(stream, size, &avail_size);
+ i_stream_try_alloc(stream, size, &avail_size);
i_assert(avail_size >= size);
}
return stream->w_buffer + stream->pos;
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib-mail/istream-dot.c
--- a/src/lib-mail/istream-dot.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib-mail/istream-dot.c Thu Jun 28 01:30:50 2012 +0300
@@ -44,7 +44,7 @@
i_assert(size != 0);
}
- if (!i_stream_get_buffer_space(stream, size, &avail))
+ if (!i_stream_try_alloc(stream, size, &avail))
return -2;
return 1;
}
@@ -113,7 +113,7 @@
ssize_t ret, ret1;
if (dstream->pending[0] != '\0') {
- if (!i_stream_get_buffer_space(stream, 1, &avail))
+ if (!i_stream_try_alloc(stream, 1, &avail))
return -2;
dest = stream->pos;
(void)flush_pending(dstream, &dest);
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib-mail/istream-nonuls.c
--- a/src/lib-mail/istream-nonuls.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib-mail/istream-nonuls.c Thu Jun 28 01:30:50 2012 +0300
@@ -37,7 +37,7 @@
return ret;
data = i_stream_get_data(stream->parent, &size);
- if (!i_stream_get_buffer_space(stream, size, &avail_size))
+ if (!i_stream_try_alloc(stream, size, &avail_size))
return -2;
if (size > avail_size)
size = avail_size;
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib-ssl-iostream/istream-openssl.c
--- a/src/lib-ssl-iostream/istream-openssl.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib-ssl-iostream/istream-openssl.c Thu Jun 28 01:30:50 2012 +0300
@@ -45,7 +45,7 @@
return ret;
}
- if (!i_stream_get_buffer_space(stream, 1, &size))
+ if (!i_stream_try_alloc(stream, 1, &size))
return -2;
while ((ret = SSL_read(sstream->ssl_io->ssl,
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib/istream-base64-encoder.c
--- a/src/lib/istream-base64-encoder.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib/istream-base64-encoder.c Thu Jun 28 01:30:50 2012 +0300
@@ -52,8 +52,7 @@
if (bstream->cur_line_len == bstream->chars_per_line) {
/* @UNSAFE: end of line, add newline */
- if (!i_stream_get_buffer_space(stream,
- bstream->crlf ? 2 : 1, &avail))
+ if (!i_stream_try_alloc(stream, bstream->crlf ? 2 : 1, &avail))
return FALSE;
if (bstream->crlf)
@@ -62,7 +61,7 @@
bstream->cur_line_len = 0;
}
- i_stream_get_buffer_space(stream, (size+2)/3*4, &avail);
+ i_stream_try_alloc(stream, (size+2)/3*4, &avail);
buffer_avail = stream->buffer_size - stream->pos;
if ((size + 2) / 3 * 4 > buffer_avail) {
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib/istream-chain.c
--- a/src/lib/istream-chain.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib/istream-chain.c Thu Jun 28 01:30:50 2012 +0300
@@ -122,7 +122,7 @@
maximum buffer size */
cstream->istream.pos = 0;
if (data_size > 0) {
- if (!i_stream_get_buffer_space(&cstream->istream, data_size, &size))
+ if (!i_stream_try_alloc(&cstream->istream, data_size, &size))
i_unreached();
i_assert(size >= data_size);
}
@@ -217,7 +217,7 @@
stream->buffer = stream->w_buffer;
} else {
stream->buffer = stream->w_buffer;
- if (!i_stream_get_buffer_space(stream, pos - cur_pos, &size))
+ if (!i_stream_try_alloc(stream, pos - cur_pos, &size))
return -2;
if (pos > size)
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib/istream-concat.c
--- a/src/lib/istream-concat.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib/istream-concat.c Thu Jun 28 01:30:50 2012 +0300
@@ -71,8 +71,7 @@
maximum buffer size */
cstream->istream.pos = 0;
if (data_size > 0) {
- if (!i_stream_get_buffer_space(&cstream->istream,
- data_size, &size))
+ if (!i_stream_try_alloc(&cstream->istream, data_size, &size))
i_unreached();
i_assert(size >= data_size);
}
@@ -156,7 +155,7 @@
stream->buffer = stream->w_buffer;
} else {
stream->buffer = stream->w_buffer;
- if (!i_stream_get_buffer_space(stream, pos - cur_pos, &size))
+ if (!i_stream_try_alloc(stream, pos - cur_pos, &size))
return -2;
if (pos > size)
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib/istream-crlf.c
--- a/src/lib/istream-crlf.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib/istream-crlf.c Thu Jun 28 01:30:50 2012 +0300
@@ -30,7 +30,7 @@
i_assert(size != 0);
}
- if (!i_stream_get_buffer_space(stream, size, &avail))
+ if (!i_stream_try_alloc(stream, size, &avail))
return -2;
return 1;
}
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib/istream-file.c
--- a/src/lib/istream-file.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib/istream-file.c Thu Jun 28 01:30:50 2012 +0300
@@ -55,7 +55,7 @@
size_t size;
ssize_t ret;
- if (!i_stream_get_buffer_space(stream, 1, &size))
+ if (!i_stream_try_alloc(stream, 1, &size))
return -2;
if (stream->fd == -1) {
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib/istream-private.h
--- a/src/lib/istream-private.h Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib/istream-private.h Thu Jun 28 01:30:50 2012 +0300
@@ -54,8 +54,8 @@
void i_stream_compress(struct istream_private *stream);
void i_stream_grow_buffer(struct istream_private *stream, size_t bytes);
bool ATTR_NOWARN_UNUSED_RESULT
-i_stream_get_buffer_space(struct istream_private *stream,
- size_t wanted_size, size_t *size_r);
+i_stream_try_alloc(struct istream_private *stream,
+ size_t wanted_size, size_t *size_r);
ssize_t i_stream_read_copy_from_parent(struct istream *istream);
void i_stream_default_seek(struct istream_private *stream,
uoff_t v_offset, bool mark);
diff -r 9774ae8fff97 -r d7d1f24dde34 src/lib/istream.c
--- a/src/lib/istream.c Thu Jun 28 01:01:58 2012 +0300
+++ b/src/lib/istream.c Thu Jun 28 01:30:50 2012 +0300
@@ -495,8 +495,8 @@
}
}
-bool i_stream_get_buffer_space(struct istream_private *stream,
- size_t wanted_size, size_t *size_r)
+bool i_stream_try_alloc(struct istream_private *stream,
+ size_t wanted_size, size_t *size_r)
{
i_assert(wanted_size > 0);
@@ -521,7 +521,7 @@
struct istream_private *stream = _stream->real_stream;
size_t size2;
- i_stream_get_buffer_space(stream, size, &size2);
+ i_stream_try_alloc(stream, size, &size2);
if (size > size2)
return FALSE;
More information about the dovecot-cvs
mailing list