[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1405441 - /subversion/branches/compressed-pristines/subversion/libsvn_wc/wc_db_pristine.c

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Mon, 05 Nov 2012 12:14:00 +0000

ashod_at_apache.org 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
Received on 2012-11-05 13:14:45 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.