https://gcc.gnu.org/g:d9e3a6cfe7026975ce3689a982ccb0eb0b30aaff

commit r17-4200-gd9e3a6cfe7026975ce3689a982ccb0eb0b30aaff
Author: Iain Sandoe <[email protected]>
Date:   Thu Sep 10 19:22:00 2026 +0100

    libgm2: Avoid malloc.h as it is not portable.
    
    To declare malloc/free we should use stdlib.h/cstdlib.
    
    libgm2/ChangeLog:
    
            * libm2iso/wrapclock.cc: Use stdlib.h instead of
            malloc.h.
            * libm2iso/wrapsock.c: Likewise.
            * libm2iso/wraptime.cc: Likewise.
    
    Signed-off-by: Iain Sandoe <[email protected]>

Diff:
---
 libgm2/libm2iso/wrapclock.cc |  4 ++--
 libgm2/libm2iso/wrapsock.c   |  2 +-
 libgm2/libm2iso/wraptime.cc  | 14 +++++++++-----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/libgm2/libm2iso/wrapclock.cc b/libgm2/libm2iso/wrapclock.cc
index 31ddeb573f8a..540a8b9ae6d0 100644
--- a/libgm2/libm2iso/wrapclock.cc
+++ b/libgm2/libm2iso/wrapclock.cc
@@ -135,7 +135,7 @@ EXPORT(SetTimeRealtime) (void *ts)
 extern "C" struct timespec *
 EXPORT(InitTimespec) (void)
 {
-#if defined(HAVE_STRUCT_TIMESPEC) && defined(HAVE_MALLOC_H)
+#if defined(HAVE_STRUCT_TIMESPEC) && defined(HAVE_STDLIB_H)
   return (struct timespec *)malloc (sizeof (struct timespec));
 #else
   return NULL;
@@ -157,7 +157,7 @@ EXPORT(InitTimespec) (void)
 extern "C" struct timespec *
 EXPORT(KillTimespec) (void *ts)
 {
-#if defined(HAVE_MALLOC_H)
+#if defined(HAVE_STDLIB_H)
   free (ts);
 #endif
   return NULL;
diff --git a/libgm2/libm2iso/wrapsock.c b/libgm2/libm2iso/wrapsock.c
index 805271ef70d1..79f3db960643 100644
--- a/libgm2/libm2iso/wrapsock.c
+++ b/libgm2/libm2iso/wrapsock.c
@@ -77,7 +77,7 @@ extern void m2iso_M2RTS_RegisterModule (const char 
*modulename, const char *libn
 #include "malloc.h"
 #endif
 
-#if defined(HAVE_MALLOC_H)
+#if defined(HAVE_SIGNAL_H)
 #include "signal.h"
 #endif
 
diff --git a/libgm2/libm2iso/wraptime.cc b/libgm2/libm2iso/wraptime.cc
index ed5f05e59328..9c28f9e59f30 100644
--- a/libgm2/libm2iso/wraptime.cc
+++ b/libgm2/libm2iso/wraptime.cc
@@ -43,6 +43,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #include "time.h"
 #endif
 
+#if defined(HAVE_STDLIB_H)
+#include <stdlib.h>
+#endif
+
 #if defined(HAVE_MALLOC_H)
 #include "malloc.h"
 #endif
@@ -77,7 +81,7 @@ EXPORT(InitTimeval) (void)
 extern "C" struct timeval *
 EXPORT(KillTimeval) (void *tv)
 {
-#if defined(HAVE_MALLOC_H)
+#if defined(HAVE_STDLIB_H)
   free (tv);
 #endif
   return NULL;
@@ -85,7 +89,7 @@ EXPORT(KillTimeval) (void *tv)
 
 /* InitTimezone returns a newly created opaque type.  */
 
-#if defined(HAVE_STRUCT_TM_TM_ZONE) && defined(HAVE_MALLOC_H)
+#if defined(HAVE_STRUCT_TM_TM_ZONE) && defined(HAVE_STDLIB_H)
 extern "C" struct timezone *
 EXPORT(InitTimezone) (void)
 {
@@ -102,7 +106,7 @@ EXPORT(InitTimezone) (void)
 /* KillTimezone - deallocates the memory associated with an opaque
    type.  */
 
-#if defined(HAVE_STRUCT_TM_TM_ZONE) && defined(HAVE_MALLOC_H)
+#if defined(HAVE_STRUCT_TM_TM_ZONE) && defined(HAVE_STDLIB_H)
 extern "C" struct timezone *
 EXPORT(KillTimezone) (struct timezone *tv)
 {
@@ -119,7 +123,7 @@ EXPORT(KillTimezone) (void *tv)
 
 /* InitTM - returns a newly created opaque type.  */
 
-#if defined(HAVE_SYS_TIME_H) && defined(HAVE_MALLOC_H)
+#if defined(HAVE_SYS_TIME_H) && defined(HAVE_STDLIB_H)
 extern "C" struct tm *
 EXPORT(InitTM) (void)
 {
@@ -138,7 +142,7 @@ EXPORT(InitTM) (void)
 extern "C" struct tm *
 EXPORT(KillTM) (struct tm *tv)
 {
-#if defined(HAVE_MALLOC_H)
+#if defined(HAVE_STDLIB_H)
   free (tv);
 #endif
   return NULL;

Reply via email to