summaryrefslogtreecommitdiff
path: root/lib/memxfrm.c
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
commit3e0814cd9862b89c7a39672672937477bd87ddfb (patch)
tree159134a624e51509f40ed8823249f09a70d1dda3 /lib/memxfrm.c
parent3bebb94360f1c2333feb8d504a9fa4f96984d8b7 (diff)
Imported Upstream version 0.9.3upstream/0.9.3
Diffstat (limited to 'lib/memxfrm.c')
-rw-r--r--lib/memxfrm.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/lib/memxfrm.c b/lib/memxfrm.c
index dc6eda1..a1c6cf8 100644
--- a/lib/memxfrm.c
+++ b/lib/memxfrm.c
@@ -1,5 +1,5 @@
/* Locale dependent memory area transformation for comparison.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
@@ -45,7 +45,7 @@ memxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
allocated = (n > 0 ? n : 1);
result = (char *) malloc (allocated);
if (result == NULL)
- goto out_of_memory_2;
+ goto out_of_memory_2;
}
length = 0;
@@ -63,44 +63,44 @@ memxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
p = s;
for (;;)
{
- /* Search next NUL byte. */
- const char *q = p + strlen (p);
-
- for (;;)
- {
- size_t k;
-
- errno = 0;
- k = strxfrm (result + length, p, allocated - length);
- if (errno != 0)
- goto fail;
- if (k >= allocated - length)
- {
- /* Grow the result buffer. */
- char *new_result;
-
- allocated = 2 * allocated;
- if (allocated < 64)
- allocated = 64;
- if (result == resultbuf)
- new_result = (char *) malloc (allocated);
- else
- new_result = (char *) realloc (result, allocated);
- if (new_result == NULL)
- goto out_of_memory_1;
- result = new_result;
- }
- else
- {
- length += k;
- break;
- }
- }
-
- p = q + 1;
- if (p == p_end)
- break;
- result[length] = '\0';
+ /* Search next NUL byte. */
+ const char *q = p + strlen (p);
+
+ for (;;)
+ {
+ size_t k;
+
+ errno = 0;
+ k = strxfrm (result + length, p, allocated - length);
+ if (errno != 0)
+ goto fail;
+ if (k >= allocated - length)
+ {
+ /* Grow the result buffer. */
+ char *new_result;
+
+ allocated = 2 * allocated;
+ if (allocated < 64)
+ allocated = 64;
+ if (result == resultbuf)
+ new_result = (char *) malloc (allocated);
+ else
+ new_result = (char *) realloc (result, allocated);
+ if (new_result == NULL)
+ goto out_of_memory_1;
+ result = new_result;
+ }
+ else
+ {
+ length += k;
+ break;
+ }
+ }
+
+ p = q + 1;
+ if (p == p_end)
+ break;
+ result[length] = '\0';
length++;
}
}
@@ -110,7 +110,7 @@ memxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
{
char *memory = (char *) realloc (result, length > 0 ? length : 1);
if (memory != NULL)
- result = memory;
+ result = memory;
}
s[n] = orig_sentinel;