Author: ivan
Date: Sun Jun 7 17:07:30 2015
New Revision: 1684047
URL: http://svn.apache.org/r1684047
Log:
Avoid callers of svn__compress() and svn__decompress() construct fake
svn_stringbuf_t instance.
* subversion/include/private/svn_subr_private.h
* subversion/libsvn_subr/compress.c
(svn__compress, svn__decompress): Replace IN parameter of type
svn_stringbuf_t with DATA/LEN.
* subversion/libsvn_delta/svndiff.c
(zlib_decode): Remove.
(window_handler): Just pass DATA/LEN to svn__compress() instead of
construction fake svn_stringbuf_t.
(decode_window): Call svn__decompress() directly without zlib_decode()
helper.
* subversion/libsvn_fs_fs/revprops.c
(parse_packed_revprops, repack_revprops, svn_fs_fs__copy_revprops):
Adapt calls to svn__compress() and svn__decompress().
* subversion/libsvn_fs_x/revprops.c
(parse_packed_revprops, repack_revprops, svn_fs_fs__copy_revprops):
Adapt calls to svn__compress() and svn__decompress().
* subversion/libsvn_subr/packed_data.c
(write_stream_data, read_stream_data): Adapt calls to
svn__compress() and svn__decompress().
Modified:
subversion/trunk/subversion/include/private/svn_subr_private.h
subversion/trunk/subversion/libsvn_delta/svndiff.c
subversion/trunk/subversion/libsvn_fs_fs/revprops.c
subversion/trunk/subversion/libsvn_fs_x/revprops.c
subversion/trunk/subversion/libsvn_subr/compress.c
subversion/trunk/subversion/libsvn_subr/packed_data.c
Modified: subversion/trunk/subversion/include/private/svn_subr_private.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_subr_private.h?rev=1684047&r1=1684046&r2=1684047&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_subr_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_subr_private.h Sun Jun 7
17:07:30 2015
@@ -537,20 +537,21 @@ svn__decode_uint(apr_uint64_t *val,
const unsigned char *p,
const unsigned char *end);
-/* Get the data from IN, compress it according to the specified
- * COMPRESSION_METHOD and write the result to OUT.
+/* Compress the data from DATA with length LEN, it according to the
+ * specified COMPRESSION_METHOD and write the result to OUT.
* SVN__COMPRESSION_NONE is valid for COMPRESSION_METHOD.
*/
svn_error_t *
-svn__compress(svn_stringbuf_t *in,
+svn__compress(const void *data, apr_size_t len,
svn_stringbuf_t *out,
int compression_method);
-/* Get the compressed data from IN, decompress it and write the result to
- * OUT. Return an error if the decompressed size is larger than LIMIT.
+/* Decompress the compressed data from DATA with length LEN and write the
+ * result to OUT. Return an error if the decompressed size is larger than
+ * LIMIT.
*/
svn_error_t *
-svn__decompress(svn_stringbuf_t *in,
+svn__decompress(const void *data, apr_size_t len,
svn_stringbuf_t *out,
apr_size_t limit);
Modified: subversion/trunk/subversion/libsvn_delta/svndiff.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/svndiff.c?rev=1684047&r1=1684046&r2=1684047&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/svndiff.c (original)
+++ subversion/trunk/subversion/libsvn_delta/svndiff.c Sun Jun 7 17:07:30 2015
@@ -215,19 +215,17 @@ window_handler(svn_txdelta_window_t *win
append_encoded_int(header, window->tview_len);
if (eb->version == 1)
{
- SVN_ERR(svn__compress(instructions, i1, eb->compression_level));
+ SVN_ERR(svn__compress(instructions->data, instructions->len,
+ i1, eb->compression_level));
instructions = i1;
}
append_encoded_int(header, instructions->len);
if (eb->version == 1)
{
svn_stringbuf_t *compressed = svn_stringbuf_create_empty(pool);
- svn_stringbuf_t *original = svn_stringbuf_create_empty(pool);
- original->data = (char *)window->new_data->data; /* won't be modified */
- original->len = window->new_data->len;
- original->blocksize = window->new_data->len + 1;
- SVN_ERR(svn__compress(original, compressed, eb->compression_level));
+ SVN_ERR(svn__compress(window->new_data->data, window->new_data->len,
+ compressed, eb->compression_level));
newdata = svn_stringbuf__morph_into_string(compressed);
}
else
@@ -483,21 +481,6 @@ count_and_verify_instructions(int *ninst
return SVN_NO_ERROR;
}
-static svn_error_t *
-zlib_decode(const unsigned char *in, apr_size_t inLen, svn_stringbuf_t *out,
- apr_size_t limit)
-{
- /* construct a fake string buffer as parameter to svn__decompress.
- This is fine as that function never writes to it. */
- svn_stringbuf_t compressed;
- compressed.pool = NULL;
- compressed.data = (char *)in;
- compressed.len = inLen;
- compressed.blocksize = inLen + 1;
-
- return svn__decompress(&compressed, out, limit);
-}
-
/* Given the five integer fields of a window header and a pointer to
the remainder of the window contents, fill in a delta window
structure *WINDOW. New allocations will be performed in POOL;
@@ -526,10 +509,10 @@ decode_window(svn_txdelta_window_t *wind
svn_stringbuf_t *instout = svn_stringbuf_create_empty(pool);
svn_stringbuf_t *ndout = svn_stringbuf_create_empty(pool);
- SVN_ERR(zlib_decode(insend, newlen, ndout,
- SVN_DELTA_WINDOW_SIZE));
- SVN_ERR(zlib_decode(data, insend - data, instout,
- MAX_INSTRUCTION_SECTION_LEN));
+ SVN_ERR(svn__decompress(insend, newlen, ndout,
+ SVN_DELTA_WINDOW_SIZE));
+ SVN_ERR(svn__decompress(data, insend - data, instout,
+ MAX_INSTRUCTION_SECTION_LEN));
newlen = ndout->len;
data = (unsigned char *)instout->data;
Modified: subversion/trunk/subversion/libsvn_fs_fs/revprops.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/revprops.c?rev=1684047&r1=1684046&r2=1684047&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/revprops.c Sun Jun 7 17:07:30 2015
@@ -410,7 +410,8 @@ parse_packed_revprops(svn_fs_t *fs,
* length header to remove) */
svn_stringbuf_t *compressed = revprops->packed_revprops;
svn_stringbuf_t *uncompressed = svn_stringbuf_create_empty(pool);
- SVN_ERR(svn__decompress(compressed, uncompressed, APR_SIZE_MAX));
+ SVN_ERR(svn__decompress(compressed->data, compressed->len,
+ uncompressed, APR_SIZE_MAX));
/* read first revision number and number of revisions in the pack */
stream = svn_stream_from_stringbuf(uncompressed, scratch_pool);
@@ -811,7 +812,7 @@ repack_revprops(svn_fs_t *fs,
SVN_ERR(svn_stream_close(stream));
/* compress / store the data */
- SVN_ERR(svn__compress(uncompressed,
+ SVN_ERR(svn__compress(uncompressed->data, uncompressed->len,
compressed,
ffd->compress_packed_revprops
? SVN_DELTA_COMPRESSION_LEVEL_DEFAULT
@@ -1210,7 +1211,8 @@ svn_fs_fs__copy_revprops(const char *pac
SVN_ERR(svn_stream_close(pack_stream));
/* compress the content (or just store it for COMPRESSION_LEVEL 0) */
- SVN_ERR(svn__compress(uncompressed, compressed, compression_level));
+ SVN_ERR(svn__compress(uncompressed->data, uncompressed->len,
+ compressed, compression_level));
/* write the pack file content to disk */
SVN_ERR(svn_io_file_write_full(pack_file, compressed->data, compressed->len,
Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.c?rev=1684047&r1=1684046&r2=1684047&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.c Sun Jun 7 17:07:30 2015
@@ -895,7 +895,8 @@ parse_packed_revprops(svn_fs_t *fs,
* length header to remove) */
svn_stringbuf_t *compressed = revprops->packed_revprops;
svn_stringbuf_t *uncompressed = svn_stringbuf_create_empty(result_pool);
- SVN_ERR(svn__decompress(compressed, uncompressed, APR_SIZE_MAX));
+ SVN_ERR(svn__decompress(compressed->data, compressed->len,
+ uncompressed, APR_SIZE_MAX));
/* read first revision number and number of revisions in the pack */
stream = svn_stream_from_stringbuf(uncompressed, scratch_pool);
@@ -1354,7 +1355,7 @@ repack_revprops(svn_fs_t *fs,
SVN_ERR(svn_stream_close(stream));
/* compress / store the data */
- SVN_ERR(svn__compress(uncompressed,
+ SVN_ERR(svn__compress(uncompressed->data, uncompressed->len,
compressed,
ffd->compress_packed_revprops
? SVN_DELTA_COMPRESSION_LEVEL_DEFAULT
@@ -1803,7 +1804,8 @@ svn_fs_x__copy_revprops(const char *pack
SVN_ERR(svn_stream_close(pack_stream));
/* compress the content (or just store it for COMPRESSION_LEVEL 0) */
- SVN_ERR(svn__compress(uncompressed, compressed, compression_level));
+ SVN_ERR(svn__compress(uncompressed->data, uncompressed->len,
+ compressed, compression_level));
/* write the pack file content to disk */
stream = svn_stream_from_aprfile2(pack_file, FALSE, scratch_pool);
Modified: subversion/trunk/subversion/libsvn_subr/compress.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/compress.c?rev=1684047&r1=1684046&r2=1684047&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/compress.c (original)
+++ subversion/trunk/subversion/libsvn_subr/compress.c Sun Jun 7 17:07:30 2015
@@ -220,7 +220,7 @@ zlib_decode(const unsigned char *in, apr
}
svn_error_t *
-svn__compress(svn_stringbuf_t *in,
+svn__compress(const void *data, apr_size_t len,
svn_stringbuf_t *out,
int compression_method)
{
@@ -230,13 +230,13 @@ svn__compress(svn_stringbuf_t *in,
_("Unsupported compression method %d"),
compression_method);
- return zlib_encode(in->data, in->len, out, compression_method);
+ return zlib_encode(data, len, out, compression_method);
}
svn_error_t *
-svn__decompress(svn_stringbuf_t *in,
+svn__decompress(const void *data, apr_size_t len,
svn_stringbuf_t *out,
apr_size_t limit)
{
- return zlib_decode((const unsigned char*)in->data, in->len, out, limit);
+ return zlib_decode(data, len, out, limit);
}
Modified: subversion/trunk/subversion/libsvn_subr/packed_data.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/packed_data.c?rev=1684047&r1=1684046&r2=1684047&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/packed_data.c (original)
+++ subversion/trunk/subversion/libsvn_subr/packed_data.c Sun Jun 7 17:07:30
2015
@@ -561,7 +561,7 @@ write_stream_data(svn_stream_t *stream,
svn_stringbuf_t *uncompressed,
svn_stringbuf_t *compressed)
{
- SVN_ERR(svn__compress(uncompressed,
+ SVN_ERR(svn__compress(uncompressed->data, uncompressed->len,
compressed,
SVN_DELTA_COMPRESSION_LEVEL_DEFAULT));
@@ -972,7 +972,8 @@ read_stream_data(svn_stream_t *stream,
SVN_ERR(svn_stream_read_full(stream, compressed->data, &compressed->len));
compressed->data[compressed_len] = '\0';
- SVN_ERR(svn__decompress(compressed, uncompressed, uncompressed_len));
+ SVN_ERR(svn__decompress(compressed->data, compressed->len,
+ uncompressed, uncompressed_len));
return SVN_NO_ERROR;
}