Commit 3e386b9e by Richard Kenner

(xstrdup): New function.

From-SVN: r11408
parent bb380e9d
...@@ -1757,6 +1757,20 @@ xrealloc (ptr, size) ...@@ -1757,6 +1757,20 @@ xrealloc (ptr, size)
fatal ("virtual memory exhausted"); fatal ("virtual memory exhausted");
return result; return result;
} }
/* Same as `strdup' but report error if no memory available. */
char *
xstrdup (s)
register char *s;
{
register char *result = (char *) malloc (strlen (s) + 1);
if (! result)
fatal ("virtual memory exhausted");
strcpy (result, s);
return result;
}
/* Return the logarithm of X, base 2, considering X unsigned, /* Return the logarithm of X, base 2, considering X unsigned,
if X is a power of 2. Otherwise, returns -1. if X is a power of 2. Otherwise, returns -1.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment