From de508f98a705d2b2a0887be1ac0d55a213c99f80 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Thu, 9 Dec 2004 22:23:32 +0000 Subject: [project @ 2004-12-09 22:23:32 by bursa] Remove die() from squash_whitespace(). All calls need checking. svn path=/import/netsurf/; revision=1399 --- utils/utils.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'utils') 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') { -- cgit v1.2.3