[email protected] writes:
> Author: ashod
> Date: Sat Nov 3 23:51:31 2012
> New Revision: 1405441
>
> URL: http://svn.apache.org/viewvc?rev=1405441&view=rev
> Log:
> Added a helper to compress files in-memory.
> +/* Compress a complete file into a stringbuf. */
> +static svn_error_t *
> +file_to_compressed_buffer(const char *path,
> + svn_stringbuf_t **buffer,
> + apr_pool_t *pool)
Try to avoid using "pool" in new code. Use "scratch_pool" if the pool
is for allocations that do not need to persist and "result_pool" for
allocations need to persist beyond the call.
In this case you probably want two pools: scratch_pool and result_pool.
> +{
> + apr_file_t *file;
> + svn_stream_t *stream_in, *stream_out;
> +
> + *buffer = NULL;
> +
> + SVN_ERR(svn_io_file_open(&file, path, APR_READ, APR_OS_DEFAULT, pool));
> + stream_in = svn_stream_from_aprfile2(file, FALSE, pool);
> +
> + *buffer = svn_stringbuf_create_empty(pool);
> + stream_out = svn_stream_compressed(svn_stream_from_stringbuf(*buffer,
> + pool),
> + pool);
> + /* Copy and close the streams. */
> + SVN_ERR(svn_stream_copy3(stream_in, stream_out,
> + NULL, NULL, pool));
> + return SVN_NO_ERROR;
> +}
> +
--
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download