/* MI Command Set - MI parser.
- Copyright (C) 2000-2013 Free Software Foundation, Inc.
+ Copyright (C) 2000-2016 Free Software Foundation, Inc.
Contributed by Cygnus Solutions (a Red Hat company).
#include "charset.h"
#include <ctype.h>
-#include <string.h>
#include "cli/cli-utils.h"
#include "language.h"
{
const char *chp = args;
int argc = 0;
- char **argv = xmalloc ((argc + 1) * sizeof (char *));
+ char **argv = XNEWVEC (char *, argc + 1);
argv[argc] = NULL;
while (1)
return;
}
/* Create the buffer and copy characters in. */
- arg = xmalloc ((len + 1) * sizeof (char));
+ arg = XNEWVEC (char, len + 1);
chp = start;
len = 0;
while (*chp != '\0' && *chp != '"')
chp++;
}
len = chp - start;
- arg = xmalloc ((len + 1) * sizeof (char));
+ arg = XNEWVEC (char, len + 1);
strncpy (arg, start, len);
arg[len] = '\0';
break;
}
}
/* Append arg to argv. */
- argv = xrealloc (argv, (argc + 2) * sizeof (char *));
+ argv = XRESIZEVEC (char *, argv, argc + 2);
argv[argc++] = arg;
argv[argc] = NULL;
}
static void
mi_parse_cleanup (void *arg)
{
- mi_parse_free (arg);
+ mi_parse_free ((struct mi_parse *) arg);
}
struct mi_parse *
mi_parse (const char *cmd, char **token)
{
const char *chp;
- struct mi_parse *parse = XMALLOC (struct mi_parse);
+ struct mi_parse *parse = XNEW (struct mi_parse);
struct cleanup *cleanup;
memset (parse, 0, sizeof (*parse));
/* Find/skip any token and then extract it. */
for (chp = cmd; *chp >= '0' && *chp <= '9'; chp++)
;
- *token = xmalloc (chp - cmd + 1);
+ *token = (char *) xmalloc (chp - cmd + 1);
memcpy (*token, cmd, (chp - cmd));
(*token)[chp - cmd] = '\0';
for (; *chp && !isspace (*chp); chp++)
;
- parse->command = xmalloc (chp - tmp + 1);
+ parse->command = (char *) xmalloc (chp - tmp + 1);
memcpy (parse->command, tmp, chp - tmp);
parse->command[chp - tmp] = '\0';
}