subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r936647 - /subversion/trunk/subversion/libsvn_subr/stream.c
Date Thu, 22 Apr 2010 08:24:02 GMT
Author: stsp
Date: Thu Apr 22 08:24:01 2010
New Revision: 936647

URL: http://svn.apache.org/viewvc?rev=936647&view=rev
Log:
Prepare for work on issue #3616. 

svn_stream_mark_t is an opaque type, but was also a real struct with
file-level visibility, supporting mark and seek support for two distinct
types of streams. Give each their own svn_stream_mark_t definition,
rather than sharing a common definition. This is more consistent with
the way wrapper streams will wrap marks set on underlying streams.

* subversion/libsvn_subr/stream.c
  (svn_stream_mark_t): Remove.
  (mark_apr, mark_stringbuf_stream): New structs replacing the above.
  (mark_handler_apr, seek_handler_apr, mark_handler_stringbuf,
   seek_handler_stringbuf): With some cast magic, these functions can
   use the mark types specific to their stream, rather than sharing a
   common svn_stream_mark_t structure.

Review by: julianfoad
           rhuijben

Modified:
    subversion/trunk/subversion/libsvn_subr/stream.c

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=936647&r1=936646&r2=936647&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Thu Apr 22 08:24:01 2010
@@ -57,14 +57,6 @@ struct svn_stream_t {
   svn_io_line_transformer_cb_t line_transformer_cb;
 };
 
-/* A type which represents a mark on a stream. */
-struct svn_stream_mark_t {
-  union {
-    apr_off_t apr;
-    apr_size_t stringbuf;
-  } m;
-};
-
 
 /*** Generic streams. ***/
 
@@ -677,6 +669,10 @@ struct baton_apr {
   apr_off_t end;
 };
 
+/* svn_stream_mark_t for streams backed by APR files. */
+struct mark_apr {
+  apr_off_t off;
+};
 
 static svn_error_t *
 read_handler_apr(void *baton, char *buffer, apr_size_t *len)
@@ -727,9 +723,12 @@ static svn_error_t *
 mark_handler_apr(void *baton, svn_stream_mark_t **mark, apr_pool_t *pool)
 {
   struct baton_apr *btn = baton;
-  (*mark) = apr_palloc(pool, sizeof(**mark));
-  (*mark)->m.apr = 0;
-  SVN_ERR(svn_io_file_seek(btn->file, APR_CUR, &(*mark)->m.apr, btn->pool));
+  struct mark_apr *mark_apr;
+
+  mark_apr = apr_palloc(pool, sizeof(*mark_apr));
+  mark_apr->off = 0;
+  SVN_ERR(svn_io_file_seek(btn->file, APR_CUR, &mark_apr->off, btn->pool));
+  *mark = (svn_stream_mark_t *)mark_apr;
   return SVN_NO_ERROR;
 }
 
@@ -737,7 +736,10 @@ static svn_error_t *
 seek_handler_apr(void *baton, svn_stream_mark_t *mark)
 {
   struct baton_apr *btn = baton;
-  SVN_ERR(svn_io_file_seek(btn->file, APR_SET, &mark->m.apr, btn->pool));
+  struct mark_apr *mark_apr;
+
+  mark_apr = (struct mark_apr *)mark;
+  SVN_ERR(svn_io_file_seek(btn->file, APR_SET, &mark_apr->off, btn->pool));
   return SVN_NO_ERROR;
 }
 
@@ -1395,6 +1397,11 @@ struct stringbuf_stream_baton
   apr_size_t amt_read;
 };
 
+/* svn_stream_mark_t for streams backed by stringbufs. */
+struct stringbuf_stream_mark {
+    apr_size_t pos; 
+};
+
 static svn_error_t *
 read_handler_stringbuf(void *baton, char *buffer, apr_size_t *len)
 {
@@ -1427,17 +1434,25 @@ reset_handler_stringbuf(void *baton)
 static svn_error_t *
 mark_handler_stringbuf(void *baton, svn_stream_mark_t **mark, apr_pool_t *pool)
 {
-  struct stringbuf_stream_baton *btn = baton;
-  (*mark) = apr_palloc(pool, sizeof(**mark));
-  (*mark)->m.stringbuf = btn->amt_read;
+  struct stringbuf_stream_baton *btn;
+  struct stringbuf_stream_mark *stringbuf_stream_mark;
+
+  btn = baton;
+  stringbuf_stream_mark = apr_palloc(pool, sizeof(*stringbuf_stream_mark));
+  stringbuf_stream_mark->pos = btn->amt_read;
+  *mark = (svn_stream_mark_t *)stringbuf_stream_mark;
   return SVN_NO_ERROR;
 }
 
 static svn_error_t *
 seek_handler_stringbuf(void *baton, svn_stream_mark_t *mark)
 {
-  struct stringbuf_stream_baton *btn = baton;
-  btn->amt_read = mark->m.stringbuf;
+  struct stringbuf_stream_baton *btn;
+  struct stringbuf_stream_mark *stringbuf_stream_mark;
+
+  btn = baton;
+  stringbuf_stream_mark = (struct stringbuf_stream_mark *)mark;
+  btn->amt_read = stringbuf_stream_mark->pos;
   return SVN_NO_ERROR;
 }
 



Mime
View raw message