Commit 62f9bd39 authored by Alexandre Julliard's avatar Alexandre Julliard

tools: Consistently use xmalloc/xrealloc/xstrdup everywhere.

parent 78ef8cf4
......@@ -521,7 +521,7 @@ arg_list: arg { check_arg_attrs($1); $$ = append_var( NULL, $1 ); }
;
args: arg_list
| arg_list ',' ELLIPSIS { $$ = append_var( $1, make_var(strdup("...")) ); }
| arg_list ',' ELLIPSIS { $$ = append_var( $1, make_var(xstrdup("...")) ); }
;
/* split into two rules to get bison to resolve a tVOID conflict */
......@@ -3107,9 +3107,9 @@ static void check_async_uuid(type_t *iface)
if (args) LIST_FOR_EACH_ENTRY(arg, args, var_t, entry)
{
if (is_attr(arg->attrs, ATTR_IN) || !is_attr(arg->attrs, ATTR_OUT))
begin_args = append_var(begin_args, copy_var(arg, strdup(arg->name), arg_in_attrs));
begin_args = append_var(begin_args, copy_var(arg, xstrdup(arg->name), arg_in_attrs));
if (is_attr(arg->attrs, ATTR_OUT))
finish_args = append_var(finish_args, copy_var(arg, strdup(arg->name), arg_out_attrs));
finish_args = append_var(finish_args, copy_var(arg, xstrdup(arg->name), arg_out_attrs));
}
begin_func = copy_var(func, strmake("Begin_%s", func->name), NULL);
......
......@@ -489,8 +489,8 @@ static void init_argv0_dir( const char *argv0 )
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static int pathname[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
size_t path_size = PATH_MAX;
char *path = malloc( path_size );
if (path && !sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
char *path = xmalloc( path_size );
if (!sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
dir = realpath( path, NULL );
free( path );
#else
......
......@@ -1319,15 +1319,13 @@ static void init_symbol_dumper(struct symbol_dumper* sd)
{
sd->depth = 0;
sd->alloc = 16;
sd->stack = malloc(sd->alloc * sizeof(sd->stack[0]));
sd->stack = xmalloc(sd->alloc * sizeof(sd->stack[0]));
}
static void push_symbol_dumper(struct symbol_dumper* sd, const union codeview_symbol* sym, unsigned end)
{
if (!sd->stack) return;
if (sd->depth >= sd->alloc &&
!(sd->stack = realloc(sd->stack, (sd->alloc *= 2) * sizeof(sd->stack[0]))))
return;
if (sd->depth >= sd->alloc) sd->stack = xrealloc(sd->stack, (sd->alloc *= 2) * sizeof(sd->stack[0]));
sd->stack[sd->depth].end = end;
sd->stack[sd->depth].sym = sym;
sd->depth++;
......
......@@ -490,8 +490,6 @@ static char *demangle_datatype (char **str, compound_type *ct,
iter++;
/* Apply our constraints to the base type (struct xxx *) */
stripped = xstrdup (sym->arg_text [0]);
if (!stripped)
fatal ("Out of Memory");
/* If we're a reference, re-use the pointer already in the type */
if (!(ct->flags & CT_BY_REFERENCE))
......
......@@ -657,8 +657,8 @@ static void init_argv0_dir( const char *argv0 )
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static int pathname[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
size_t path_size = PATH_MAX;
char *path = malloc( path_size );
if (path && !sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
char *path = xmalloc( path_size );
if (!sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
dir = realpath( path, NULL );
free( path );
#else
......@@ -1114,7 +1114,7 @@ static void build(struct options* opts)
* -xlll: lll is the language (c, c++, etc.)
*/
output_file = strdup( opts->output_name ? opts->output_name : "a.out" );
output_file = xstrdup( opts->output_name ? opts->output_name : "a.out" );
/* 'winegcc -o app xxx.exe.so' only creates the load script */
if (opts->files.count == 1 && strendswith(opts->files.str[0], ".exe.so"))
......@@ -1648,7 +1648,7 @@ int main(int argc, char **argv)
switch (opts.args.str[i][1])
{
case 'B':
str = strdup(option_arg);
str = xstrdup(option_arg);
if (strendswith(str, "/")) str[strlen(str) - 1] = 0;
strarray_add(&opts.prefix, str);
raw_linker_arg = 1;
......@@ -1824,17 +1824,17 @@ int main(int argc, char **argv)
{
if (!strcmp(Wl.str[j], "--image-base") && j < Wl.count - 1)
{
opts.image_base = strdup( Wl.str[++j] );
opts.image_base = xstrdup( Wl.str[++j] );
continue;
}
if (!strcmp(Wl.str[j], "--section-alignment") && j < Wl.count - 1)
{
opts.section_align = strdup( Wl.str[++j] );
opts.section_align = xstrdup( Wl.str[++j] );
continue;
}
if (!strcmp(Wl.str[j], "--file-alignment") && j < Wl.count - 1)
{
opts.file_align = strdup( Wl.str[++j] );
opts.file_align = xstrdup( Wl.str[++j] );
continue;
}
if (!strcmp(Wl.str[j], "--large-address-aware"))
......@@ -1849,12 +1849,12 @@ int main(int argc, char **argv)
}
if (!strcmp(Wl.str[j], "--subsystem") && j < Wl.count - 1)
{
opts.subsystem = strdup( Wl.str[++j] );
opts.subsystem = xstrdup( Wl.str[++j] );
continue;
}
if (!strcmp(Wl.str[j], "--entry") && j < Wl.count - 1)
{
opts.entry_point = strdup( Wl.str[++j] );
opts.entry_point = xstrdup( Wl.str[++j] );
continue;
}
if (!strcmp(Wl.str[j], "-delayload") && j < Wl.count - 1)
......@@ -1864,7 +1864,7 @@ int main(int argc, char **argv)
}
if (!strcmp(Wl.str[j], "--debug-file") && j < Wl.count - 1)
{
opts.debug_file = strdup( Wl.str[++j] );
opts.debug_file = xstrdup( Wl.str[++j] );
continue;
}
if (!strcmp(Wl.str[j], "--whole-archive") ||
......@@ -1877,7 +1877,7 @@ int main(int argc, char **argv)
}
if (!strcmp(Wl.str[j], "--out-implib"))
{
opts.out_implib = strdup( Wl.str[++j] );
opts.out_implib = xstrdup( Wl.str[++j] );
continue;
}
if (!strcmp(Wl.str[j], "-static")) linking = -1;
......
......@@ -157,8 +157,8 @@ static void init_argv0_dir( const char *argv0 )
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static int pathname[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
size_t path_size = PATH_MAX;
char *path = malloc( path_size );
if (path && !sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
char *path = xmalloc( path_size );
if (!sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
dir = realpath( path, NULL );
free( path );
#else
......
......@@ -307,8 +307,8 @@ static void init_argv0_dir( const char *argv0 )
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static int pathname[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
size_t path_size = PATH_MAX;
char *path = malloc( path_size );
if (path && !sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
char *path = xmalloc( path_size );
if (!sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 ))
dir = realpath( path, NULL );
free( path );
#else
......@@ -401,7 +401,7 @@ static void option_callback( int optc, char *optarg )
optarg++;
/* fall through */
case 'o':
if (!output_name) output_name = strdup(optarg);
if (!output_name) output_name = xstrdup(optarg);
else error("Too many output files.\n");
break;
case 'O':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment