[GRASS5] RE: [GRASS-CVS] scott: grass6/raster/simwe/r.sim.water main.c,1.9,1.10

Hi,

does anyone know how the malloc.h should be done below?
AFAIK, GRASS is free of malloc.h except for below code.

Markus

-----Original Message-----
From: grass-commit-admin@grass.itc.it on behalf of grass@intevation.de
Sent: Sun 2006-01-22 05:06
To: grass-commit@grass.itc.it
Subject: [GRASS-CVS] scott: grass6/raster/simwe/r.sim.water main.c,1.9,1.10

Author: scott

Update of /grassrepository/grass6/raster/simwe/r.sim.water
In directory doto:/tmp/cvs-serv11961

Modified Files:
  main.c
Log Message:
Added check for Apple compiler in check for malloc.h - may not be appropriate check?

Index: main.c

RCS file: /grassrepository/grass6/raster/simwe/r.sim.water/main.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- main.c 19 Jan 2006 12:57:28 -0000 1.9
+++ main.c 22 Jan 2006 04:06:06 -0000 1.10
@@ -42,8 +42,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
+#if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE_CC__))
/* <malloc.h> has been replaced by <stdlib.h> in *BSD. */
+/* and Mac OS X is based on BSD, but apparently doesn't define those symbols */
+/* At the moment, if APPLE_CC is defined, we're using Apple's compilers - */
+/* but that probably isn't the best test. What is a better way ? */
#include <malloc.h>
#endif

_______________________________________________
grass-commit mailing list
grass-commit@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-commit

Markus Neteler wrote:

does anyone know how the malloc.h should be done below?
AFAIK, GRASS is free of malloc.h except for below code.

Simply remove it.

The only legitimate reason to include malloc.h is if you want to use
certain platform-specific features such as mallopt() or providing your
own allocator.

The standard ANSI functions (malloc, calloc, realloc, free) are all
declared in <stdlib.h>.

Usage of <malloc.h> normally indicates that the programmer grew up
with certain broken MS-DOS compilers (e.g. early versions of Borland
C) which used that header. Such compilers haven't been in widespread
use for at least a decade, although some compilers may support the use
of <malloc.h> for backward compatibility.

--
Glynn Clements <glynn@gclements.plus.com>