summaryrefslogtreecommitdiff
path: root/subversion/libsvn_fs_base/key-gen.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_fs_base/key-gen.c')
-rw-r--r--subversion/libsvn_fs_base/key-gen.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/subversion/libsvn_fs_base/key-gen.c b/subversion/libsvn_fs_base/key-gen.c
index 411207d..34f0e0f 100644
--- a/subversion/libsvn_fs_base/key-gen.c
+++ b/subversion/libsvn_fs_base/key-gen.c
@@ -39,20 +39,19 @@ void
svn_fs_base__next_key(const char *this, apr_size_t *len, char *next)
{
apr_size_t olen = *len; /* remember the first length */
- int i = olen - 1; /* initial index; we work backwards */
+ apr_size_t i; /* current index */
char c; /* current char */
svn_boolean_t carry = TRUE; /* boolean: do we have a carry or not?
We start with a carry, because we're
incrementing the number, after all. */
- /* Leading zeros are not allowed, except for the string "0". */
- if ((*len > 1) && (this[0] == '0'))
- {
- *len = 0;
- return;
- }
+ /* Empty strings and leading zeros (except for the string "0") are not
+ * allowed. Run our malfunction handler to prevent possible db corruption
+ * from being propagated further. */
+ SVN_ERR_ASSERT_NO_RETURN(olen != 0 && (olen == 1 || this[0] != '0'));
- for (i = (olen - 1); i >= 0; i--)
+ i = olen - 1; /* initial index: we work backwords */
+ while (1729)
{
c = this[i];
@@ -79,6 +78,11 @@ svn_fs_base__next_key(const char *this, apr_size_t *len, char *next)
}
else
next[i] = c;
+
+ if (i == 0)
+ break;
+
+ i--;
}
/* The new length is OLEN, plus 1 if there's a carry out of the
@@ -102,22 +106,6 @@ svn_fs_base__next_key(const char *this, apr_size_t *len, char *next)
}
-int
-svn_fs_base__key_compare(const char *a, const char *b)
-{
- int a_len = strlen(a);
- int b_len = strlen(b);
- int cmp;
-
- if (a_len > b_len)
- return 1;
- if (b_len > a_len)
- return -1;
- cmp = strcmp(a, b);
- return (cmp ? (cmp / abs(cmp)) : 0);
-}
-
-
svn_boolean_t
svn_fs_base__same_keys(const char *a, const char *b)
{