Author: brane
Date: Fri Jan 16 19:43:42 2026
New Revision: 1931378
Log:
On the better-pristines branch: Make a minor improvement to the internal
spillbuf API and its documentation. No funcitonal change.
* subversion/include/private/svn_subr_private.h
(SVN_SPILLBUF__DELETE_ON_CLOSE,
SVN_SPILLBUF__SPILL_ALL_CONTENTS): New flag constants.
(svn_spillbuf__create_extended): Use a parameter with bitwise flags
instead of a series of boolean arguments. This makes calls of this
function self-documenting.
(svn_spillbuf__create): Improve the documentation.
* subversion/libsvn_subr/spillbuf.c
(struct svn_spillbuf_t): Move the byte-sized boolean flags to the end
of the struct, possibly reducing space used by alignment padding.
(init_spillbuf, init_spillbuf_extended): Remove single-use private functions.
(svn_spillbuf__create_extended): Update the parameters and inline the
code that was previously in init_spillbuf_extended().
(svn_spillbuf__create): Call svn_spillbuf__create_extended().
* subversion/tests/libsvn_subr/spillbuf-test.c: Update all calls to
svn_spillbuf__create_extended() to reflect its changed parameters.
Modified:
subversion/branches/better-pristines/subversion/include/private/svn_subr_private.h
subversion/branches/better-pristines/subversion/libsvn_subr/spillbuf.c
subversion/branches/better-pristines/subversion/tests/libsvn_subr/spillbuf-test.c
Modified: subversion/branches/better-pristines/subversion/include/private/svn_subr_private.h
==============================================================================
--- subversion/branches/better-pristines/subversion/include/private/svn_subr_private.h Fri Jan 16 18:45:02 2026 (r1931377)
+++ subversion/branches/better-pristines/subversion/include/private/svn_subr_private.h Fri Jan 16 19:43:42 2026 (r1931378)
@@ -89,21 +89,35 @@ extern "C" {
typedef struct svn_spillbuf_t svn_spillbuf_t;
-/* Create a spill buffer. */
-svn_spillbuf_t *
-svn_spillbuf__create(apr_size_t blocksize,
- apr_size_t maxsize,
- apr_pool_t *result_pool);
+/* Delete all files created by spillbuf operations when the spillbuf
+ is destroyed. This is the behaviour of svn_spilbuff__create(). */
+#define SVN_SPILLBUF__DELETE_ON_CLOSE 0x01
+
+/* When maxsize is reached, spill all contents buffered in memory to the
+ spill file, not just the overflow. This ensures that the spill file,
+ if one is created, will contain all the data written to the spillbuf. */
+#define SVN_SPILLBUF__SPILL_ALL_CONTENTS 0x02
-/* Create a spill buffer, with extra parameters. */
+/* Create a spill buffer. FLAGS is a bitwise-or combination of the
+ constants defined above. See svn_io_open_unique_file3() in svn_io.h
+ for a description of the semantics of the DIRPATH parameter. */
svn_spillbuf_t *
svn_spillbuf__create_extended(apr_size_t blocksize,
apr_size_t maxsize,
- svn_boolean_t delete_on_close,
- svn_boolean_t spill_all_contents,
+ unsigned flags,
const char* dirpath,
apr_pool_t *result_pool);
+/* Create a spill buffer with:
+ FLAGS = SVN_SPILLBUF__DELETE_ON_CLOSE
+ DIRPATH = NULL
+ The created spillbuf's behaviour is what we need when it's used as
+ a temporary buffer for connecting push-like and pull-like streams. */
+svn_spillbuf_t *
+svn_spillbuf__create(apr_size_t blocksize,
+ apr_size_t maxsize,
+ apr_pool_t *result_pool);
+
/* Determine how much content is stored in the spill buffer. */
svn_filesize_t
svn_spillbuf__get_size(const svn_spillbuf_t *buf);
Modified: subversion/branches/better-pristines/subversion/libsvn_subr/spillbuf.c
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_subr/spillbuf.c Fri Jan 16 18:45:02 2026 (r1931377)
+++ subversion/branches/better-pristines/subversion/libsvn_subr/spillbuf.c Fri Jan 16 19:43:42 2026 (r1931378)
@@ -74,6 +74,12 @@ struct svn_spillbuf_t {
/* How much content remains in SPILL. */
svn_filesize_t spill_size;
+ /* The directory in which the spill file is created. */
+ const char *dirpath;
+
+ /* The name of the temporary spill file. */
+ const char *filename;
+
/* When false, do not delete the spill file when it is closed. */
svn_boolean_t delete_on_close;
@@ -81,12 +87,6 @@ struct svn_spillbuf_t {
larger than MAXSIZE, all spillbuf contents will be written to the
spill file. */
svn_boolean_t spill_all_contents;
-
- /* The directory in which the spill file is created. */
- const char *dirpath;
-
- /* The name of the temporary spill file. */
- const char *filename;
};
@@ -112,36 +112,21 @@ struct svn_spillbuf_reader_t {
apr_size_t save_pos;
};
-
-/* Extended spillbuf initialization. */
-static void
-init_spillbuf_extended(svn_spillbuf_t *buf,
- apr_size_t blocksize,
- apr_size_t maxsize,
- svn_boolean_t delete_on_close,
- svn_boolean_t spill_all_contents,
- const char *dirpath,
- apr_pool_t *result_pool)
+svn_spillbuf_t *
+svn_spillbuf__create_extended(apr_size_t blocksize,
+ apr_size_t maxsize,
+ unsigned flags,
+ const char *dirpath,
+ apr_pool_t *result_pool)
{
+ svn_spillbuf_t *buf = apr_pcalloc(result_pool, sizeof(*buf));
buf->pool = result_pool;
buf->blocksize = blocksize;
buf->maxsize = maxsize;
- buf->delete_on_close = delete_on_close;
- buf->spill_all_contents = spill_all_contents;
+ buf->delete_on_close = 0 != (flags & SVN_SPILLBUF__DELETE_ON_CLOSE);
+ buf->spill_all_contents = 0 != (flags & SVN_SPILLBUF__SPILL_ALL_CONTENTS);
buf->dirpath = dirpath;
-}
-
-/* Common constructor for initializing spillbufs.
- Used by svn_spillbuf__create, svn_spilbuff__reader_create. */
-static void
-init_spillbuf(svn_spillbuf_t *buf,
- apr_size_t blocksize,
- apr_size_t maxsize,
- apr_pool_t *result_pool)
-{
- init_spillbuf_extended(buf, blocksize, maxsize,
- TRUE, FALSE, NULL,
- result_pool);
+ return buf;
}
svn_spillbuf_t *
@@ -149,25 +134,11 @@ svn_spillbuf__create(apr_size_t blocksiz
apr_size_t maxsize,
apr_pool_t *result_pool)
{
- svn_spillbuf_t *buf = apr_pcalloc(result_pool, sizeof(*buf));
- init_spillbuf(buf, blocksize, maxsize, result_pool);
- return buf;
-}
-
-
-svn_spillbuf_t *
-svn_spillbuf__create_extended(apr_size_t blocksize,
- apr_size_t maxsize,
- svn_boolean_t delete_on_close,
- svn_boolean_t spill_all_contents,
- const char *dirpath,
- apr_pool_t *result_pool)
-{
- svn_spillbuf_t *buf = apr_pcalloc(result_pool, sizeof(*buf));
- init_spillbuf_extended(buf, blocksize, maxsize,
- delete_on_close, spill_all_contents, dirpath,
- result_pool);
- return buf;
+ return svn_spillbuf__create_extended(
+ blocksize, maxsize,
+ SVN_SPILLBUF__DELETE_ON_CLOSE, /* flags */
+ NULL, /* dirpath */
+ result_pool);
}
svn_filesize_t
Modified: subversion/branches/better-pristines/subversion/tests/libsvn_subr/spillbuf-test.c
==============================================================================
--- subversion/branches/better-pristines/subversion/tests/libsvn_subr/spillbuf-test.c Fri Jan 16 18:45:02 2026 (r1931377)
+++ subversion/branches/better-pristines/subversion/tests/libsvn_subr/spillbuf-test.c Fri Jan 16 19:43:42 2026 (r1931378)
@@ -98,7 +98,10 @@ test_spillbuf_basic_spill_all(apr_pool_t
{
apr_size_t len = strlen(basic_data); /* Don't include basic_data's NUL */
svn_spillbuf_t *buf =
- svn_spillbuf__create_extended(len, 10 * len, TRUE, TRUE, NULL, pool);
+ svn_spillbuf__create_extended(len, 10 * len,
+ SVN_SPILLBUF__DELETE_ON_CLOSE
+ | SVN_SPILLBUF__SPILL_ALL_CONTENTS,
+ NULL, pool);
return test_spillbuf__basic(pool, len, buf);
}
@@ -159,8 +162,8 @@ test_spillbuf_callback_spill_all(apr_poo
svn_spillbuf_t *buf = svn_spillbuf__create_extended(
sizeof(basic_data) /* blocksize */,
10 * sizeof(basic_data) /* maxsize */,
- TRUE /* delte on close */,
- TRUE /* spill all data */,
+ SVN_SPILLBUF__DELETE_ON_CLOSE
+ | SVN_SPILLBUF__SPILL_ALL_CONTENTS,
NULL, pool);
return test_spillbuf__callback(pool, buf);
}
@@ -247,8 +250,8 @@ test_spillbuf_file_spill_all(apr_pool_t
svn_spillbuf_t *buf = svn_spillbuf__create_extended(
altsize /* blocksize */,
2 * sizeof(basic_data) /* maxsize */,
- TRUE /* delte on close */,
- TRUE /* spill all data */,
+ SVN_SPILLBUF__DELETE_ON_CLOSE
+ | SVN_SPILLBUF__SPILL_ALL_CONTENTS,
NULL, pool);
return test_spillbuf__file(pool, altsize, buf);
}
@@ -298,8 +301,8 @@ test_spillbuf_interleaving_spill_all(apr
svn_spillbuf_t *buf = svn_spillbuf__create_extended(
8 /* blocksize */,
15 /* maxsize */,
- TRUE /* delte on close */,
- TRUE /* spill all data */,
+ SVN_SPILLBUF__DELETE_ON_CLOSE
+ | SVN_SPILLBUF__SPILL_ALL_CONTENTS,
NULL, pool);
return test_spillbuf__interleaving(pool, buf);
}
@@ -433,8 +436,8 @@ test_spillbuf_rwfile_spill_all(apr_pool_
svn_spillbuf_t *buf = svn_spillbuf__create_extended(
4 /* blocksize */,
10 /* maxsize */,
- TRUE /* delte on close */,
- TRUE /* spill all data */,
+ SVN_SPILLBUF__DELETE_ON_CLOSE
+ | SVN_SPILLBUF__SPILL_ALL_CONTENTS,
NULL, pool);
return test_spillbuf__rwfile(pool, buf);
}
@@ -504,8 +507,8 @@ test_spillbuf_eof_spill_all(apr_pool_t *
svn_spillbuf_t *buf = svn_spillbuf__create_extended(
4 /* blocksize */,
10 /* maxsize */,
- TRUE /* delte on close */,
- TRUE /* spill all data */,
+ SVN_SPILLBUF__DELETE_ON_CLOSE
+ | SVN_SPILLBUF__SPILL_ALL_CONTENTS,
NULL, pool);
return test_spillbuf__eof(pool, buf);
}
@@ -552,8 +555,8 @@ test_spillbuf_file_attrs_spill_all(apr_p
svn_spillbuf_t *buf = svn_spillbuf__create_extended(
4 /* blocksize */,
10 /* maxsize */,
- TRUE /* delte on close */,
- TRUE /* spill all data */,
+ SVN_SPILLBUF__DELETE_ON_CLOSE
+ | SVN_SPILLBUF__SPILL_ALL_CONTENTS,
NULL, pool);
return test_spillbuf__file_attrs(pool, TRUE, buf);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.