printf(fmt "\n", ##args); \
} while (0)
+#define dm_malloc malloc
+#define dm_free free
+#define dm_strdup strdup
+
/* needed to include args.h */
#define ARG_COUNTABLE 0x00000001
#define ARG_GROUPABLE 0x00000002
def->num = (uint64_t)atoi(name);
if (val_enum == conststr_VAL)
- def->str = strdup(name);
+ def->str = dm_strdup(name);
if (val_enum == lv_VAL) {
if (strstr(name, "_"))
char *start;
oo = &oo_lines[oo_line_count++];
- oo->name = strdup(name);
+ oo->name = dm_strdup(name);
if ((colon = strstr(oo->name, ":")))
*colon = '\0';
}
start = strstr(line, ":") + 2;
- oo->line = strdup(start);
+ oo->line = dm_strdup(start);
}
/* Support OO_FOO: continuing on multiple lines. */
/* +2 = 1 space between old and new + 1 terminating \0 */
len = strlen(old_line) + strlen(new_line) + 2;
- line = malloc(len);
+ line = dm_malloc(len);
if (!line) {
log_error("Parsing command defs: no memory");
exit(EXIT_FAILURE);
strcat(line, " ");
strcat(line, new_line);
- free(oo->line);
+ dm_free(oo->line);
oo->line = line;
}
exit(EXIT_FAILURE);
}
- if (!(line = strdup(oo_line)))
+ if (!(line = dm_strdup(oo_line)))
exit(EXIT_FAILURE);
split_line(line, &line_argc, line_argv, ' ');
add_optional_opt_line(cmd, line_argc, line_argv);
- free(line);
+ dm_free(line);
}
/*
exit(EXIT_FAILURE);
}
- if (!(line = strdup(oo_line)))
+ if (!(line = dm_strdup(oo_line)))
exit(EXIT_FAILURE);
split_line(line, &line_argc, line_argv, ' ');
add_required_opt_line(cmd, line_argc, line_argv);
- free(line);
+ dm_free(line);
}
/* Process what follows command_name, which are required opt/pos args. */
else if (!strncmp(arg, "--", 2)) {
if (!rule->opts) {
- if (!(rule->opts = malloc(MAX_RULE_OPTS * sizeof(int)))) {
+ if (!(rule->opts = dm_malloc(MAX_RULE_OPTS * sizeof(int)))) {
log_error("Parsing command defs: no mem");
exit(EXIT_FAILURE);
}
}
if (!rule->check_opts) {
- if (!(rule->check_opts = malloc(MAX_RULE_OPTS * sizeof(int)))) {
+ if (!(rule->check_opts = dm_malloc(MAX_RULE_OPTS * sizeof(int)))) {
log_error("Parsing command defs: no mem");
exit(EXIT_FAILURE);
}
cmd = &commands[cmd_count];
cmd->command_index = cmd_count;
cmd_count++;
- cmd->name = strdup(name);
+ cmd->name = dm_strdup(name);
if (run_name && strcmp(run_name, name)) {
skip = 1;
*/
if (is_desc_line(line_argv[0]) && !skip) {
- char *desc = strdup(line_orig);
+ char *desc = dm_strdup(line_orig);
if (cmd->desc) {
int newlen = strlen(cmd->desc) + strlen(desc) + 2;
- char *newdesc = malloc(newlen);
+ char *newdesc = dm_malloc(newlen);
if (newdesc) {
memset(newdesc, 0, newlen);
snprintf(newdesc, newlen, "%s %s", cmd->desc, desc);
cmd->desc = newdesc;
- free(desc);
+ dm_free(desc);
}
} else
cmd->desc = desc;
}
if (is_id_line(line_argv[0])) {
- cmd->command_id = strdup(line_argv[1]);
+ cmd->command_id = dm_strdup(line_argv[1]);
continue;
}
if (strstr(str, "|")) {
int len = strlen(str);
- line = strdup(str);
+ line = dm_strdup(str);
split_line(line, &line_argc, line_argv, '|');
for (i = 0; i < line_argc; i++) {
if (i) {