Author: kotkov Date: Mon Jul 31 15:43:03 2017 New Revision: 1803546 URL: http://svn.apache.org/viewvc?rev=1803546&view=rev Log: Following up on r1803140, comment on why the memory usage of the new svn_txdelta_to_svndiff_stream() function is limited, and on the fact that we rely on the implementation detail of svn_txdelta_to_svndiff3().
See the related discussion in: https://lists.apache.org/thread.html/51c8418956457d2739e2672340fbcacc86d9ee40be7f8dae447e998d@%3Cdev.subversion.apache.org%3E * subversion/libsvn_delta/svndiff.c (window_handler, svndiff_stream_write_fn, svn_txdelta_to_svndiff_stream): Add comments and cross-link them. Modified: subversion/trunk/subversion/libsvn_delta/svndiff.c Modified: subversion/trunk/subversion/libsvn_delta/svndiff.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/svndiff.c?rev=1803546&r1=1803545&r2=1803546&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_delta/svndiff.c (original) +++ subversion/trunk/subversion/libsvn_delta/svndiff.c Mon Jul 31 15:43:03 2017 @@ -245,6 +245,8 @@ encode_window(svn_stringbuf_t **instruct return SVN_NO_ERROR; } +/* Note: When changing things here, check the related comment in + the svn_txdelta_to_svndiff_stream() function. */ static svn_error_t * window_handler(svn_txdelta_window_t *window, void *baton) { @@ -1009,6 +1011,9 @@ svndiff_stream_write_fn(void *baton, con { svndiff_stream_baton_t *b = baton; + /* The memory usage here is limited, as this buffer doesn't grow + beyond the (header size + max window size in svndiff format). + See the comment in svn_txdelta_to_svndiff_stream(). */ svn_stringbuf_appendbytes(b->window_buffer, data, *len); return SVN_NO_ERROR; @@ -1076,6 +1081,12 @@ svn_txdelta_to_svndiff_stream(svn_txdelt push_stream = svn_stream_create(baton, pool); svn_stream_set_write(push_stream, svndiff_stream_write_fn); + /* We rely on the implementation detail of the svn_txdelta_to_svndiff3() + function, namely, on how the window_handler() function behaves. + As long as it writes one svndiff window at a time to the target + stream, the memory usage of this function (in other words, how + much data can be accumulated in the internal 'window_buffer') + is limited. */ svn_txdelta_to_svndiff3(&baton->handler, &baton->handler_baton, push_stream, svndiff_version, compression_level, pool);