This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
scm_must_* and K&R C
- To: guile@sourceware.cygnus.com
- Subject: scm_must_* and K&R C
- From: forcer <forcer@mindless.com>
- Date: Sat, 28 Aug 1999 19:03:06 +0200
Guile uses K&R C for backwards compatibility. That's ok, but it
gets annoying when you have to cast your return values of
scm_must_malloc or the parameter for scm_must_free each time just
to prevent those stupid warnings.
A small patch to fix that for ANSI C compilers is appended
diff -urN guile-core/libguile/gc.c guile-core-fixed/libguile/gc.c
--- guile-core/libguile/gc.c Thu Aug 26 13:12:28 1999
+++ guile-core-fixed/libguile/gc.c Sat Aug 28 05:00:51 1999
@@ -1431,8 +1431,13 @@
*
* The limit scm_mtrigger may be raised by this allocation.
*/
+#ifdef __STDC__
+void *
+scm_must_malloc (scm_sizet size, const char *what)
+#else
char *
scm_must_malloc (scm_sizet size, const char *what)
+#endif /* __STDC__ */
{
char *ptr;
unsigned long nm = scm_mallocated + size;
@@ -1471,11 +1476,19 @@
/* scm_must_realloc
* is similar to scm_must_malloc.
*/
+#ifdef __STDC__
+void *
+scm_must_realloc (void *where,
+ scm_sizet old_size,
+ scm_sizet size,
+ const char *what)
+#else
char *
scm_must_realloc (char *where,
scm_sizet old_size,
scm_sizet size,
const char *what)
+#endif
{
char *ptr;
scm_sizet nm = scm_mallocated + size - old_size;
@@ -1510,9 +1523,15 @@
return 0; /* never reached */
}
+#ifdef __STDC__
+void
+scm_must_free (obj)
+ void *obj;
+#else
void
scm_must_free (obj)
char *obj;
+#endif /* __STDC__ */
{
if (obj)
free (obj);
diff -urN guile-core/libguile/gc.h guile-core-fixed/libguile/gc.h
--- guile-core/libguile/gc.h Wed Jun 16 22:39:08 1999
+++ guile-core-fixed/libguile/gc.h Sat Aug 28 04:59:00 1999
@@ -94,12 +94,21 @@
extern void scm_mark_locations (SCM_STACKITEM x[], scm_sizet n);
extern int scm_cellp (SCM value);
extern void scm_gc_sweep (void);
+#ifdef __STDC__
+
+extern void * scm_must_malloc (scm_sizet len, const char *what);
+extern void * scm_must_realloc (void *where,
+ scm_sizet olen, scm_sizet len,
+ const char *what);
+extern void scm_must_free (void *obj);
+#else
extern char * scm_must_malloc (scm_sizet len, const char *what);
extern char * scm_must_realloc (char *where,
scm_sizet olen, scm_sizet len,
const char *what);
-extern void scm_done_malloc (long size);
extern void scm_must_free (char *obj);
+#endif /* __STDC__ */
+extern void scm_done_malloc (long size);
extern void scm_remember (SCM * ptr);
extern SCM scm_return_first (SCM elt, ...);
extern SCM scm_permanent_object (SCM obj);
HTH,
-forcer
--
((email . "forcer@mindless.com") (www . "http://forcix.cx/")
(irc . "forcer@#StarWars (IRCnet)") (gpg . "/other/forcer.gpg"))