(xstrdup): New function.

From-SVN: r11408
This commit is contained in:
Richard Kenner 1996-03-04 08:36:14 -05:00
parent bb380e9d21
commit 3e386b9e9d
1 changed files with 14 additions and 0 deletions

View File

@ -1757,6 +1757,20 @@ xrealloc (ptr, size)
fatal ("virtual memory exhausted");
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,
if X is a power of 2. Otherwise, returns -1.