mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-09 09:19:09 +02:00
add dupeString wrapper function
This function calls strdup and exits on failure.
This commit is contained in:
parent
b7282c1a90
commit
4272a5299a
2 changed files with 12 additions and 0 deletions
|
|
@ -62,6 +62,17 @@ void *reallocMem(void *p, size_t n)
|
|||
return s;
|
||||
}
|
||||
|
||||
char *dupeString(char *s)
|
||||
{
|
||||
char *c;
|
||||
|
||||
if (!(c = strdup(s))) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
char *initString(int *l)
|
||||
{
|
||||
*l = 0;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ extern char *EMPTYSTRING;
|
|||
|
||||
void *allocMem(size_t n);
|
||||
void *reallocMem(void *p, size_t n);
|
||||
char *dupeString(char *s);
|
||||
char *initString(int *l);
|
||||
void stringAndString(char **s, int *l, const char *t);
|
||||
void stringAndBytes(char **s, int *l, const char *t, int cnt);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue