corosync-cfgtool.c: handle strdup failure gracefully

* tools/corosync-cfgtool.c (xstrdup): New function.
(main): Use it in place of strdup.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2100 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Jim Meyering 2009-04-20 18:26:22 +00:00
parent cd154d63e6
commit f5edd27d1d

View File

@ -245,6 +245,17 @@ static void usage_do (void)
printf ("\t-H\tShutdown corosync cleanly on this node.\n");
}
static char *
xstrdup (char const *s)
{
char *p = strdup (s);
if (p)
return (char *) p;
printf ("exhausted virtual memory\n");
exit (1);
}
int main (int argc, char *argv[]) {
const char *options = "srl:u:v:k:a:hH";
int opt;
@ -267,11 +278,11 @@ int main (int argc, char *argv[]) {
break;
case 'l':
service_load = 1;
service = strdup (optarg);
service = xstrdup (optarg);
break;
case 'u':
service_unload = 1;
service = strdup (optarg);
service = xstrdup (optarg);
break;
case 'k':
nodeid = atoi (optarg);