summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2004-10-23 19:13:26 +0000
committerAndreas Schwab <schwab@suse.de>2004-10-23 19:13:26 +0000
commit0c78ba4610e15c25b2c2b1dbd815a5c1fd71e8e1 (patch)
tree8e874eeee738c74f002338b271cb35f262176f83 /gdb
parent7b42cb57f8135bb47a3f17af98c2688ea5977ba6 (diff)
downloadgdb-0c78ba4610e15c25b2c2b1dbd815a5c1fd71e8e1.tar.gz
* ada-lang.c (grow_vect): Return the new array instead of
expecting pointer to pointer to avoid violation of aliasing rules. * ada-lang.h (GROW_VECT): Adapt call to grow_vect.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/ada-lang.c11
-rw-r--r--gdb/ada-lang.h4
3 files changed, 14 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 12485fa0ef7..0df3786c700 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2004-10-23 Andreas Schwab <schwab@suse.de>
+
+ * ada-lang.c (grow_vect): Return the new array instead of
+ expecting pointer to pointer to avoid violation of aliasing rules.
+ * ada-lang.h (GROW_VECT): Adapt call to grow_vect.
+
2004-10-23 Ulrich Weigand <uweigand@de.ibm.com>
* s390-tdep.c (enum pv_boolean): Remove.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 275e3a0a96e..00e61a47467 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -319,20 +319,21 @@ extract_string (CORE_ADDR addr, char *buf)
while (buf[char_index - 1] != '\000');
}
-/* Assuming *OLD_VECT points to an array of *SIZE objects of size
+/* Assuming VECT points to an array of *SIZE objects of size
ELEMENT_SIZE, grow it to contain at least MIN_SIZE objects,
- updating *OLD_VECT and *SIZE as necessary. */
+ updating *SIZE as necessary and returning the (new) array. */
-void
-grow_vect (void **old_vect, size_t * size, size_t min_size, int element_size)
+void *
+grow_vect (void *vect, size_t *size, size_t min_size, int element_size)
{
if (*size < min_size)
{
*size *= 2;
if (*size < min_size)
*size = min_size;
- *old_vect = xrealloc (*old_vect, *size * element_size);
+ vect = xrealloc (vect, *size * element_size);
}
+ return vect;
}
/* True (non-zero) iff TARGET matches FIELD_NAME up to any trailing
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 18a662a0730..3df4aa496c8 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -171,9 +171,9 @@ extern struct task_entry *task_list;
least M objects, updating V and S as necessary. */
#define GROW_VECT(v, s, m) \
- if ((s) < (m)) grow_vect ((void**) &(v), &(s), (m), sizeof(*(v)));
+ if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v));
-extern void grow_vect (void **, size_t *, size_t, int);
+extern void *grow_vect (void *, size_t *, size_t, int);
extern int ada_get_field_index (const struct type *type,
const char *field_name,