Created a common xstrdup function.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@973 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
65b28a80a4
commit
72055744b9
1
proto.h
1
proto.h
@ -77,6 +77,7 @@ BOOL pstcache_init(uint8 cache_id);
|
|||||||
int main(int argc, char *argv[]);
|
int main(int argc, char *argv[]);
|
||||||
void generate_random(uint8 * random);
|
void generate_random(uint8 * random);
|
||||||
void *xmalloc(int size);
|
void *xmalloc(int size);
|
||||||
|
char *xstrdup(const char *s);
|
||||||
void *xrealloc(void *oldmem, int size);
|
void *xrealloc(void *oldmem, int size);
|
||||||
void xfree(void *mem);
|
void xfree(void *mem);
|
||||||
void error(char *format, ...);
|
void error(char *format, ...);
|
||||||
|
20
rdesktop.c
20
rdesktop.c
@ -382,12 +382,7 @@ main(int argc, char *argv[])
|
|||||||
locale = setlocale(LC_ALL, "");
|
locale = setlocale(LC_ALL, "");
|
||||||
if (locale)
|
if (locale)
|
||||||
{
|
{
|
||||||
locale = strdup(locale);
|
locale = xstrdup(locale);
|
||||||
if (locale == NULL)
|
|
||||||
{
|
|
||||||
perror("strdup");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -941,6 +936,19 @@ xmalloc(int size)
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* strdup */
|
||||||
|
char *
|
||||||
|
xstrdup(const char *s)
|
||||||
|
{
|
||||||
|
char *mem = strdup(s);
|
||||||
|
if (mem == NULL)
|
||||||
|
{
|
||||||
|
perror("strdup");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
/* realloc; exit if out of memory */
|
/* realloc; exit if out of memory */
|
||||||
void *
|
void *
|
||||||
xrealloc(void *oldmem, int size)
|
xrealloc(void *oldmem, int size)
|
||||||
|
@ -50,7 +50,7 @@ wave_out_open(void)
|
|||||||
|
|
||||||
if (dsp_dev == NULL)
|
if (dsp_dev == NULL)
|
||||||
{
|
{
|
||||||
dsp_dev = strdup("/dev/dsp");
|
dsp_dev = xstrdup("/dev/dsp");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
|
if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
|
||||||
|
@ -54,7 +54,7 @@ wave_out_open(void)
|
|||||||
|
|
||||||
if (dsp_dev == NULL)
|
if (dsp_dev == NULL)
|
||||||
{
|
{
|
||||||
dsp_dev = strdup("/dev/audio");
|
dsp_dev = xstrdup("/dev/audio");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
|
if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
|
||||||
|
@ -166,12 +166,7 @@ xkeymap_from_locale(const char *locale)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
/* Create a working copy */
|
/* Create a working copy */
|
||||||
str = strdup(locale);
|
str = xstrdup(locale);
|
||||||
if (str == NULL)
|
|
||||||
{
|
|
||||||
perror("strdup");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Truncate at dot and at */
|
/* Truncate at dot and at */
|
||||||
ptr = strrchr(str, '.');
|
ptr = strrchr(str, '.');
|
||||||
|
Loading…
Reference in New Issue
Block a user