Various type and cast bits.

This commit is contained in:
nhkeni
2022-03-16 18:18:52 -04:00
parent e51026aee1
commit a64a666f78
12 changed files with 28 additions and 14 deletions

View File

@@ -150,4 +150,15 @@ dupstr(const char *string)
return strcpy((char *) alloc(strlen(string) + 1), string);
}
/* similar for reasonable size strings, but return the length of the input as well */
char *
dupstr_n(const char *string, unsigned int *lenout)
{
size_t len = strlen(string);
if(len >= LARGEST_INT)
panic("string too long");
*lenout = (unsigned int) len;
return strcpy((char *) alloc((unsigned)len + 1), string);
}
/*alloc.c*/