This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH RFA] mi-main.c: Fix memory leaks and compilation problems
- To: Kevin Buettner <kevinb at cygnus dot com>
- Subject: Re: [PATCH RFA] mi-main.c: Fix memory leaks and compilation problems
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 09 Jul 2001 10:24:05 -0400
- Cc: gdb-patches at sources dot redhat dot com
- References: <1010709064143.ZM9950@ocotillo.lan>
> I ran into some more compilation problems in attempting to compile
> mi-main.c with the native compiler on AIX 5.
>
> In mi_cmd_data_write_register_values(), the fact that the xmalloc()
> cast didn't match the declaration of ``buffer'' caused the compiler to
> complain. In mi_cmd_data_write_memory(), it was the declaration of
> ``buffer'' as an ``unsigned char *'' that gave the compiler problems
> when it came to one of the later calls in which buffer was passed as a
> parameter. (unsigned char * didn't match char *.) I changed the type
> of buffer to void * and removed the cast to fix this problem.
>
> I also noticed that the space allocated to ``buffer'' in both functions
> wasn't being freed up, so I added a cleanup to handle that problem.
>
> Okay to commit?
>
> * mi-main.c (mi_cmd_data_write_register_values)
> (mi_cmd_data_write_memory): Change type of ``buffer'' to
> ``void *''. Don't cast return value from xmalloc(). Add
> a cleanup to free the xmalloc'd buffer.
Yes, definitly. Thanks!
Andrew