summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@cygnus.com>1999-01-21 09:47:36 -0800
committerRichard Henderson <rth@gcc.gnu.org>1999-01-21 09:47:36 -0800
commit470b68c0a905424b48946238ab2016d0a720d7ae (patch)
tree50ef143756292df471dad464af598c9175f80804
parentd202e8aa05a8335dc8c25e04c396a453b2a2645e (diff)
downloadgcc-470b68c0a905424b48946238ab2016d0a720d7ae.tar.gz
cccp.c (xrealloc): Call malloc given a NULL old pointer.
* cccp.c (xrealloc): Call malloc given a NULL old pointer. * collect2.c, cppalloc.c, gcc.c, genattr.c, genattrtab.c: Likewise. * gencodes.c, genconfig.c, genemit.c, genextract.c: Likewise. * genflags.c, genopinit.c, genoutput.c, genpeep.c: Likewise. * genrecog.c, mips-tfile.c, protoize.c: Likewise. From-SVN: r24806
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/cccp.c6
-rw-r--r--gcc/collect2.c14
-rw-r--r--gcc/cppalloc.c6
-rw-r--r--gcc/gcc.c14
-rw-r--r--gcc/genattr.c14
-rw-r--r--gcc/genattrtab.c14
-rw-r--r--gcc/gencodes.c14
-rw-r--r--gcc/genconfig.c14
-rw-r--r--gcc/genemit.c14
-rw-r--r--gcc/genextract.c14
-rw-r--r--gcc/genflags.c14
-rw-r--r--gcc/genopinit.c14
-rw-r--r--gcc/genoutput.c14
-rw-r--r--gcc/genpeep.c14
-rw-r--r--gcc/genrecog.c14
-rw-r--r--gcc/mips-tfile.c6
-rw-r--r--gcc/protoize.c6
18 files changed, 147 insertions, 69 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 67dad253e44..eb38b7e16d1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+Thu Jan 21 17:45:18 1999 Richard Henderson <rth@cygnus.com>
+
+ * configure.in ({rs6000|powerpc}-ibm-aix4.[12]*): Add missing `then'.
+
+ * cccp.c (xrealloc): Call malloc given a NULL old pointer.
+ * collect2.c, cppalloc.c, gcc.c, genattr.c, genattrtab.c: Likewise.
+ * gencodes.c, genconfig.c, genemit.c, genextract.c: Likewise.
+ * genflags.c, genopinit.c, genoutput.c, genpeep.c: Likewise.
+ * genrecog.c, mips-tfile.c, protoize.c: Likewise.
+
Thu Jan 21 19:44:55 1999 Michael Meissner <meissner@cygnus.com>
* configure.in ({rs6000|powerpc}-ibm-aix4.[12]*): If
diff --git a/gcc/cccp.c b/gcc/cccp.c
index 39f2dac3580..166c6ad1fc7 100644
--- a/gcc/cccp.c
+++ b/gcc/cccp.c
@@ -10743,7 +10743,11 @@ xrealloc (old, size)
PTR old;
size_t size;
{
- register PTR ptr = (PTR) realloc (old, size);
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
if (!ptr)
memory_full ();
return ptr;
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 2184e0e2398..36b4cd16f0b 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -531,14 +531,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR value = (PTR) realloc (ptr, size);
- if (value == 0)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (ptr == 0)
fatal ("virtual memory exhausted");
- return value;
+ return ptr;
}
int
diff --git a/gcc/cppalloc.c b/gcc/cppalloc.c
index 880a56dba62..07b6ce18a2f 100644
--- a/gcc/cppalloc.c
+++ b/gcc/cppalloc.c
@@ -60,7 +60,11 @@ xrealloc (old, size)
PTR old;
size_t size;
{
- register PTR ptr = (PTR) realloc (old, size);
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
if (ptr == 0)
memory_full ();
return ptr;
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 79ad1c38527..673cc275460 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -5219,14 +5219,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR value = (PTR) realloc (ptr, size);
- if (value == 0)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (ptr == 0)
fatal ("virtual memory exhausted");
- return value;
+ return ptr;
}
static char *
diff --git a/gcc/genattr.c b/gcc/genattr.c
index b676be5140f..348de94018e 100644
--- a/gcc/genattr.c
+++ b/gcc/genattr.c
@@ -210,14 +210,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index fc2f8840b1e..cfe2757a6c1 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -5753,14 +5753,18 @@ extend_range (range, min, max)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
PTR
diff --git a/gcc/gencodes.c b/gcc/gencodes.c
index 60659e3d7f1..ca67dc30625 100644
--- a/gcc/gencodes.c
+++ b/gcc/gencodes.c
@@ -68,14 +68,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genconfig.c b/gcc/genconfig.c
index 6a72e263da0..60c0e97d6bd 100644
--- a/gcc/genconfig.c
+++ b/gcc/genconfig.c
@@ -257,14 +257,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genemit.c b/gcc/genemit.c
index 81eefa96cbc..ed7cd05be49 100644
--- a/gcc/genemit.c
+++ b/gcc/genemit.c
@@ -691,14 +691,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genextract.c b/gcc/genextract.c
index 8c54f613f5b..a6ae3dfdbae 100644
--- a/gcc/genextract.c
+++ b/gcc/genextract.c
@@ -356,14 +356,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genflags.c b/gcc/genflags.c
index 043cd30f8e9..0d97f387c4a 100644
--- a/gcc/genflags.c
+++ b/gcc/genflags.c
@@ -188,14 +188,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genopinit.c b/gcc/genopinit.c
index 2b11c72549f..5c6524f671a 100644
--- a/gcc/genopinit.c
+++ b/gcc/genopinit.c
@@ -293,14 +293,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genoutput.c b/gcc/genoutput.c
index 04667fee0ee..c76a45181e8 100644
--- a/gcc/genoutput.c
+++ b/gcc/genoutput.c
@@ -914,14 +914,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genpeep.c b/gcc/genpeep.c
index 4330b48dd8d..50c86a941c3 100644
--- a/gcc/genpeep.c
+++ b/gcc/genpeep.c
@@ -396,14 +396,18 @@ xmalloc (size)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
static void
diff --git a/gcc/genrecog.c b/gcc/genrecog.c
index bcc47f0a6d3..4eb159fe799 100644
--- a/gcc/genrecog.c
+++ b/gcc/genrecog.c
@@ -1671,14 +1671,18 @@ xstrdup (input)
}
PTR
-xrealloc (ptr, size)
- PTR ptr;
+xrealloc (old, size)
+ PTR old;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
- if (!result)
+ register PTR ptr;
+ if (ptr)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (!ptr)
fatal ("virtual memory exhausted");
- return result;
+ return ptr;
}
PTR
diff --git a/gcc/mips-tfile.c b/gcc/mips-tfile.c
index 95683f34eec..588f4efedc3 100644
--- a/gcc/mips-tfile.c
+++ b/gcc/mips-tfile.c
@@ -5710,7 +5710,11 @@ xrealloc (ptr, size)
PTR ptr;
size_t size;
{
- register PTR result = (PTR) realloc (ptr, size);
+ register PTR result;
+ if (ptr)
+ result = (PTR) realloc (ptr, size);
+ else
+ result = (PTR) malloc (size);
if (!result)
fatal ("Virtual memory exhausted.");
diff --git a/gcc/protoize.c b/gcc/protoize.c
index 44c2dbe6676..4979c04c14f 100644
--- a/gcc/protoize.c
+++ b/gcc/protoize.c
@@ -608,7 +608,11 @@ xrealloc (old_space, byte_count)
pointer_type old_space;
size_t byte_count;
{
- register pointer_type rv = (pointer_type) realloc (old_space, byte_count);
+ register pointer_type rv;
+ if (old_space)
+ rv = (pointer_type) realloc (old_space, byte_count);
+ else
+ rv = (pointer_type) malloc (byte_count);
if (rv == NULL)
{
fprintf (stderr, "\n%s: virtual memory exceeded\n", pname);