On Friday 21 July 2006 19:20, Eli Zaretskii wrote: > > From: Vladimir Prus > > Date: Fri, 21 Jul 2006 15:35:29 +0400 > > Cc: gdb-patches@sources.redhat.com > > > > > > + if (!data->character_data) > > > > + data->character_data = (char *)malloc (len + 1); > > > > + else > > > > + { > > > > + current_size = strlen (data->character_data); > > > > + data->character_data = (char *)realloc (data->character_data, > > > > + current_size + len + > > > > 1); > > > > > > Why do we need to cast the results of malloc and realloc? > > > > Ah, yea, we don't need this in C. > > In fact, I think you should replace these with xmalloc and xrealloc. Here's a patch that does exactly that, and is also based on the current mainline (and so uses target_read_stralloc). 2006-07-31 Vladimir Prus * Makefile.in (SFILES): Add memory-map.c (memory_map_h): New. (target_h): Add dependency on memory-map.h. (remote.o): Likewise. * exceptions.h (enum errors): New value XML_MEMORY_MAP_ERROR. * remote.c: (struct remote_state): New fields current_memory_map and fetched_memory_map. (init_remote_state, remote_open_1): Reset the above. (PACKET_qXfer_memory_map): New. (remote_protocol_features): Register qXfer:memory-map:read. (remote_xfer_partial): Handle TARGET_OBJECT_MEMORY_MAP. (remote_memory_map): New. (init_remote_ops): Register to_memory_map. (init_async_remote_ops): Likewise. (_initialize_remote): Register qXfer:memory-map:read. * target.c (target_memory_map): New. * target.h (enum target_object): New value TARGET_OBJECT_MEMORY_MAP. (struct target_ops): New method to_memory_map. (target_memory_map): Declare. * memory-map.c: New. * memory-map.h: New.