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

Re: svn commit: r1102060 - /subversion/trunk/subversion/libsvn_ra_serf/commit.c

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Thu, 12 May 2011 03:23:25 +0300

julianfoad_at_apache.org wrote on Wed, May 11, 2011 at 20:11:52 -0000:
> Author: julianfoad
> Date: Wed May 11 20:11:51 2011
> New Revision: 1102060
>
> URL: http://svn.apache.org/viewvc?rev=1102060&view=rev
> Log:
> Code simplification.
>
> * /home/julianfoad/src/subversion-d/subversion/libsvn_ra_serf/commit.c

Wrong path, also in some other commits today.

(And thanks for the simplifications!)

> (derive_old_val): Remove a level of indirection, type casts and memory
> allocations. Add an output flag instead. Add a doc string.
> (proppatch_walker): Update accordingly.
>
> Modified:
> subversion/trunk/subversion/libsvn_ra_serf/commit.c
>
> Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1102060&r1=1102059&r2=1102060&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
> +++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Wed May 11 20:11:51 2011
> @@ -671,42 +671,45 @@ typedef struct walker_baton_t {
> svn_boolean_t deleting;
> } walker_baton_t;
>
> +/* If we have (recorded in WB) the old value of the property named NS:NAME,
> + * then set *HAVE_OLD_VAL to TRUE and set *OLD_VAL_P to that old value
> + * (which may be NULL); else set *HAVE_OLD_VAL to FALSE.
> + *
> + * Allocate *OLD_VAL_P in POOL. */
> static svn_error_t *
> -derive_old_val(const svn_string_t *const * *old_val_p_p,
> +derive_old_val(svn_boolean_t *have_old_val,
> + const svn_string_t **old_val_p,
> walker_baton_t *wb,
> const char *ns,
> const char *name,
> apr_pool_t *pool)
> {
> - const svn_string_t *const *old_val_p;
> -
> - old_val_p = NULL;
> + *have_old_val = FALSE;
>
> if (wb->previous_changed_props)
> {
> - const svn_string_t *old_val;
> - old_val = svn_ra_serf__get_prop_string(wb->previous_changed_props,
> - wb->path, ns, name);
> - if (old_val)
> + const svn_string_t *val;
> + val = svn_ra_serf__get_prop_string(wb->previous_changed_props,
> + wb->path, ns, name);
> + if (val)
> {
> - old_val_p = apr_pcalloc(pool, sizeof(*old_val_p));
> - *(const svn_string_t **)old_val_p = svn_string_dup(old_val, pool);
> + *have_old_val = TRUE;
> + *old_val_p = svn_string_dup(val, pool);
> }
> }
>
> if (wb->previous_removed_props)
> {
> - const svn_string_t *old_val;
> - old_val = svn_ra_serf__get_prop_string(wb->previous_removed_props,
> - wb->path, ns, name);
> - if (old_val)
> + const svn_string_t *val;
> + val = svn_ra_serf__get_prop_string(wb->previous_removed_props,
> + wb->path, ns, name);
> + if (val)
> {
> - old_val_p = apr_pcalloc(pool, sizeof(*old_val_p));
> - *(const svn_string_t **)old_val_p = NULL;
> + *have_old_val = TRUE;
> + *old_val_p = NULL;
> }
> }
>
> - *old_val_p_p = old_val_p;
> return SVN_NO_ERROR;
> }
>
> @@ -722,7 +725,8 @@ proppatch_walker(void *baton,
> serf_bucket_t *cdata_bkt;
> serf_bucket_alloc_t *alloc;
> const char *encoding;
> - const svn_string_t *const *old_val_p;
> + svn_boolean_t have_old_val;
> + const svn_string_t *old_val;
> const svn_string_t *encoded_value;
> char *prop_name;
>
> @@ -733,15 +737,15 @@ proppatch_walker(void *baton,
> else if (strcmp(ns, SVN_DAV_PROP_NS_CUSTOM) == 0)
> prop_name = apr_pstrcat(pool, "C:", name, (char *)NULL);
>
> - SVN_ERR(derive_old_val(&old_val_p, wb, ns, name, pool));
> + SVN_ERR(derive_old_val(&have_old_val, &old_val, wb, ns, name, pool));
>
> /* Jump through hoops to work with D:remove and its val = (""-for-NULL)
> * representation. */
> if (wb->filter != filter_all_props)
> {
> - if (wb->filter == filter_props_with_old_value && ! old_val_p)
> + if (wb->filter == filter_props_with_old_value && ! have_old_val)
> return SVN_NO_ERROR;
> - if (wb->filter == filter_props_without_old_value && old_val_p)
> + if (wb->filter == filter_props_without_old_value && have_old_val)
> return SVN_NO_ERROR;
> }
> if (wb->deleting)
> @@ -770,14 +774,14 @@ proppatch_walker(void *baton,
> "V:" SVN_DAV__OLD_VALUE__ABSENT, "1",
> NULL);
>
> - if (old_val_p)
> + if (have_old_val)
> {
> const char *encoding2;
> const svn_string_t *encoded_value2;
> serf_bucket_t *cdata_bkt2;
>
> SVN_ERR(get_encoding_and_cdata(&encoding2, &encoded_value2,
> - alloc, *old_val_p, pool));
> + alloc, old_val, pool));
>
> if (encoded_value2)
> {
>
>
Received on 2011-05-12 02:24:12 CEST

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.