aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-27 19:25:54 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-27 19:25:54 +0000
commit3e5ee396d5c2121dac4690197edac5a19a99d18f (patch)
treeec0babb2e42927baccf3217d096e069fa9e49e16 /libgfortran
parent2d8c056945e012656f4eda6a2aa355224ced8ea1 (diff)
* trans-array.c (gfc_tran_allocate_array_storage): Use new memory
allocation interface. (gfc_conv_ array_parameter): Ditto. (gfc_trans_auto_array_allocation): Ditto. Also free the memory. * trans-array.c: Update prototype. * trans-decl.c (gfc_build_builtin_function_decls): Update prototypes. (gfc_trans_auto_character_variable): Use new memory alloc interface. * trans-expr.c (gfc_conv_string_tmp): Ditto. (gfc_conv_function_call): Use gfc_conv_string_tmp. * trans-stmt.c (gfc_do_allocate): Use new memory alloc interface. * trans-intrinsic.c (gfc_conv_intrinsic_trim): Ditto. * trans.h (gfc_ss_info): Remove unused pdata field. * trans.c (gfc_create_var_np): Change T to V. libgfortran * intrinsics/string_intrinsics.c: Use new memory allocation interface. * libgfortran.h: Ditto. * m4/in_pack.m4: Ditto. * runtime/in_pack_generic.c: Ditto. * runtime/memory.c: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@74003 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/generated/in_pack_i4.c2
-rw-r--r--libgfortran/generated/in_pack_i8.c2
-rw-r--r--libgfortran/intrinsics/string_intrinsics.c2
-rw-r--r--libgfortran/libgfortran.h8
-rw-r--r--libgfortran/m4/in_pack.m42
-rw-r--r--libgfortran/runtime/in_pack_generic.c2
-rw-r--r--libgfortran/runtime/memory.c34
8 files changed, 29 insertions, 31 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index aebd846a263..12350143d29 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2003-11-27 Paul Brook <paul@nowt.org>
+
+ * intrinsics/string_intrinsics.c: Use new memory allocation interface.
+ * libgfortran.h: Ditto.
+ * m4/in_pack.m4: Ditto.
+ * runtime/in_pack_generic.c: Ditto.
+ * runtime/memory.c: Ditto.
+
2003-11-26 Richard Henderson <rth@redhat.com>
* m4/exponent.m4, m4/fraction.m4: New.
diff --git a/libgfortran/generated/in_pack_i4.c b/libgfortran/generated/in_pack_i4.c
index 4abe5b13b23..f11295718fc 100644
--- a/libgfortran/generated/in_pack_i4.c
+++ b/libgfortran/generated/in_pack_i4.c
@@ -74,7 +74,7 @@ internal_pack_4 (gfc_array_i4 * source)
return source->data;
/* Allocate storage for the destination. */
- internal_malloc_size ((void **)&destptr, ssize * 4);
+ destptr = (GFC_INTEGER_4 *)internal_malloc_size (ssize * 4);
dest = destptr;
src = source->data;
stride0 = stride[0];
diff --git a/libgfortran/generated/in_pack_i8.c b/libgfortran/generated/in_pack_i8.c
index 986387492e8..82609272e4a 100644
--- a/libgfortran/generated/in_pack_i8.c
+++ b/libgfortran/generated/in_pack_i8.c
@@ -74,7 +74,7 @@ internal_pack_8 (gfc_array_i8 * source)
return source->data;
/* Allocate storage for the destination. */
- internal_malloc_size ((void **)&destptr, ssize * 8);
+ destptr = (GFC_INTEGER_8 *)internal_malloc_size (ssize * 8);
dest = destptr;
src = source->data;
stride0 = stride[0];
diff --git a/libgfortran/intrinsics/string_intrinsics.c b/libgfortran/intrinsics/string_intrinsics.c
index e2208ebcaae..44882dac1bd 100644
--- a/libgfortran/intrinsics/string_intrinsics.c
+++ b/libgfortran/intrinsics/string_intrinsics.c
@@ -183,7 +183,7 @@ string_trim (GFC_INTEGER_4 * len, void ** dest, GFC_INTEGER_4 slen, const char *
if (*len > 0)
{
/* Allocate space for result string. */
- internal_malloc (dest, *len);
+ *dest = internal_malloc (*len);
/* copy string if necessary. */
memmove (*dest, src, *len);
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index 468776c802f..d374e828f84 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -303,16 +303,16 @@ void *get_mem (size_t) __attribute__ ((malloc));
void free_mem (void *);
#define internal_malloc_size prefix(internal_malloc_size)
-void internal_malloc_size (void **, size_t);
+void *internal_malloc_size (size_t);
#define internal_malloc prefix(internal_malloc)
-void internal_malloc (void **, GFC_INTEGER_4);
+void *internal_malloc (GFC_INTEGER_4);
#define internal_malloc64 prefix(internal_malloc64)
-void internal_malloc64 (void **, GFC_INTEGER_8);
+void *internal_malloc64 (GFC_INTEGER_8);
#define internal_free prefix(internal_free)
-void internal_free (void **);
+void internal_free (void *);
#define push_context prefix(push_context)
void push_context (void);
diff --git a/libgfortran/m4/in_pack.m4 b/libgfortran/m4/in_pack.m4
index d29bcb394a1..4998ed5f2db 100644
--- a/libgfortran/m4/in_pack.m4
+++ b/libgfortran/m4/in_pack.m4
@@ -81,7 +81,7 @@ rtype_name *
return source->data;
/* Allocate storage for the destination. */
- internal_malloc_size ((void **)&destptr, ssize * rtype_kind);
+ destptr = (rtype_name *)internal_malloc_size (ssize * rtype_kind);
dest = destptr;
src = source->data;
stride0 = stride[0];
diff --git a/libgfortran/runtime/in_pack_generic.c b/libgfortran/runtime/in_pack_generic.c
index 00fa3ee4d8c..8af4f3f0eb7 100644
--- a/libgfortran/runtime/in_pack_generic.c
+++ b/libgfortran/runtime/in_pack_generic.c
@@ -82,7 +82,7 @@ internal_pack (gfc_array_char * source)
return source->data;
/* Allocate storage for the destination. */
- internal_malloc_size (&destptr, ssize * size);
+ destptr = internal_malloc_size (ssize * size);
dest = (char *)destptr;
src = source->data;
stride0 = stride[0] * size;
diff --git a/libgfortran/runtime/memory.c b/libgfortran/runtime/memory.c
index 5ed77eb4a24..fcfc0ece2d8 100644
--- a/libgfortran/runtime/memory.c
+++ b/libgfortran/runtime/memory.c
@@ -140,16 +140,11 @@ malloc_with_header (size_t n)
/* Allocate memory for internal (compiler generated) use. */
-void
-internal_malloc_size (void **mem, size_t size)
+void *
+internal_malloc_size (size_t size)
{
malloc_t *newmem;
-#ifdef GFC_CHECK_MEMORY
- if (!mem)
- runtime_error ("Internal error: NULL mem pointer");
-#endif
-
newmem = malloc_with_header (size);
if (!newmem)
@@ -161,12 +156,12 @@ internal_malloc_size (void **mem, size_t size)
mem_root.prev->next = newmem;
mem_root.prev = newmem;
- (*mem) = DATA_POINTER (newmem);
+ return DATA_POINTER (newmem);
}
-void
-internal_malloc (void **mem, GFC_INTEGER_4 size)
+void *
+internal_malloc (GFC_INTEGER_4 size)
{
#ifdef GFC_CHECK_MEMORY
/* Under normal circumstances, this is _never_ going to happen! */
@@ -174,19 +169,19 @@ internal_malloc (void **mem, GFC_INTEGER_4 size)
runtime_error ("Attempt to allocate a non-positive amount of memory.");
#endif
- internal_malloc_size (mem, (size_t) size);
+ return internal_malloc_size ((size_t) size);
}
-void
-internal_malloc64 (void **mem, GFC_INTEGER_8 size)
+void *
+internal_malloc64 (GFC_INTEGER_8 size)
{
#ifdef GFC_CHECK_MEMORY
/* Under normal circumstances, this is _never_ going to happen! */
if (size <= 0)
runtime_error ("Attempt to allocate a non-positive amount of memory.");
#endif
- internal_malloc_size (mem, (size_t) size);
+ return internal_malloc_size ((size_t) size);
}
@@ -196,17 +191,14 @@ internal_malloc64 (void **mem, GFC_INTEGER_8 size)
allocation until pop_context. */
void
-internal_free (void **mem)
+internal_free (void *mem)
{
malloc_t *m;
if (!mem)
- runtime_error ("Internal: NULL mem pointer.");
-
- if (!*mem)
runtime_error ("Internal: Possible double free of temporary.");
- m = DATA_HEADER (*mem);
+ m = DATA_HEADER (mem);
if (m->magic != GFC_MALLOC_MAGIC)
runtime_error ("Internal: No magic memblock marker. "
@@ -219,8 +211,6 @@ internal_free (void **mem)
m->next->prev = m->prev;
free (m);
-
- (*mem) = NULL;
}
@@ -349,7 +339,7 @@ deallocate (void **mem, GFC_INTEGER_4 * stat)
}
/* Just use the internal routine. */
- internal_free (mem);
+ internal_free (*mem);
if (stat)
*stat = 0;