This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH RFA] mi-main.c: Fix memory leaks and compilation problems


> 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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]