summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-12-09 22:23:32 +0000
committerJames Bursa <james@netsurf-browser.org>2004-12-09 22:23:32 +0000
commitde508f98a705d2b2a0887be1ac0d55a213c99f80 (patch)
tree876959fbaf3d0fb52b77b3d212b5f86dd6a97aad
parentf3ce5e1e48d09cd250374d269c8e11afcdace3f2 (diff)
downloadnetsurf-de508f98a705d2b2a0887be1ac0d55a213c99f80.tar.gz
netsurf-de508f98a705d2b2a0887be1ac0d55a213c99f80.tar.bz2
[project @ 2004-12-09 22:23:32 by bursa]
Remove die() from squash_whitespace(). All calls need checking. svn path=/import/netsurf/; revision=1399
-rw-r--r--utils/utils.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/utils/utils.c b/utils/utils.c
index e2919056d..5f5647bf9 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -79,11 +79,20 @@ char * xstrdup(const char * const s)
return c;
}
-char * squash_whitespace(const char * s)
+
+/**
+ * Replace consecutive whitespace with a single space.
+ *
+ * \param s source string
+ * \return heap allocated result, or 0 on memory exhaustion
+ */
+
+char * squash_whitespace(const char *s)
{
- char * c = malloc(strlen(s) + 1);
+ char *c = malloc(strlen(s) + 1);
int i = 0, j = 0;
- if (c == 0) die("Out of memory in squash_whitespace()");
+ if (!c)
+ return 0;
do {
if (s[i] == ' ' || s[i] == '\n' || s[i] == '\r' ||
s[i] == '\t') {