Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 437612004F3 for ; Tue, 15 Aug 2017 22:20:29 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4237D1673B5; Tue, 15 Aug 2017 20:20:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 894391673A0 for ; Tue, 15 Aug 2017 22:20:28 +0200 (CEST) Received: (qmail 6897 invoked by uid 500); 15 Aug 2017 20:20:27 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 6885 invoked by uid 99); 15 Aug 2017 20:20:25 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Aug 2017 20:20:25 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 0F8573A00E6 for ; Tue, 15 Aug 2017 20:20:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1805113 - /subversion/trunk/subversion/libsvn_delta/text_delta.c Date: Tue, 15 Aug 2017 20:20:22 -0000 To: commits@subversion.apache.org From: kotkov@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170815202025.0F8573A00E6@svn01-us-west.apache.org> archived-at: Tue, 15 Aug 2017 20:20:29 -0000 Author: kotkov Date: Tue Aug 15 20:20:22 2017 New Revision: 1805113 URL: http://svn.apache.org/viewvc?rev=1805113&view=rev Log: Minor code cleanup: use svn checksum routines instead of calling apr_md5 functions in the implementation of svn_txdelta_apply(). * subversion/libsvn_delta/text_delta.c (struct apply_baton): Make md5_context an svn_checksum_ctx_t. (apply_window): Replace apr_md5_final() with svn_checksum_final(), compose and handle potential errors. Replace apr_md5_update() with svn_checksum_update(). (svn_txdelta_apply): Update context initialization. Modified: subversion/trunk/subversion/libsvn_delta/text_delta.c Modified: subversion/trunk/subversion/libsvn_delta/text_delta.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/text_delta.c?rev=1805113&r1=1805112&r2=1805113&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_delta/text_delta.c (original) +++ subversion/trunk/subversion/libsvn_delta/text_delta.c Tue Aug 15 20:20:22 2017 @@ -102,7 +102,7 @@ struct apply_baton { char *tbuf; /* Target buffer */ apr_size_t tbuf_size; /* Allocated target buffer space */ - apr_md5_ctx_t md5_context; /* Leads to result_digest below. */ + svn_checksum_ctx_t *md5_context; /* Leads to result_digest below. */ unsigned char *result_digest; /* MD5 digest of resultant fulltext; must point to at least APR_MD5_DIGESTSIZE bytes of storage. */ @@ -720,15 +720,22 @@ apply_window(svn_txdelta_window_t *windo { struct apply_baton *ab = (struct apply_baton *) baton; apr_size_t len; - svn_error_t *err; + svn_error_t *err = SVN_NO_ERROR; if (window == NULL) { /* We're done; just clean up. */ if (ab->result_digest) - apr_md5_final(ab->result_digest, &(ab->md5_context)); + { + svn_checksum_t *md5_checksum; + + err = svn_checksum_final(&md5_checksum, ab->md5_context, ab->pool); + if (!err) + memcpy(ab->result_digest, md5_checksum->digest, + svn_checksum_size(md5_checksum)); + } - err = svn_stream_close(ab->target); + err = svn_error_compose_create(err, svn_stream_close(ab->target)); svn_pool_destroy(ab->pool); return err; @@ -791,7 +798,7 @@ apply_window(svn_txdelta_window_t *windo /* Just update the context here. */ if (ab->result_digest) - apr_md5_update(&(ab->md5_context), ab->tbuf, len); + SVN_ERR(svn_checksum_update(ab->md5_context, ab->tbuf, len)); return svn_stream_write(ab->target, ab->tbuf, &len); } @@ -822,7 +829,7 @@ svn_txdelta_apply(svn_stream_t *source, ab->result_digest = result_digest; if (result_digest) - apr_md5_init(&(ab->md5_context)); + ab->md5_context = svn_checksum_ctx_create(svn_checksum_md5, subpool); if (error_info) ab->error_info = apr_pstrdup(subpool, error_info);