This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] Minimize availability of mmalloc.h
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 03 Dec 2001 23:43:36 -0500
- Subject: [patch] Minimize availability of mmalloc.h
Hello,
The attached patch deletes the #include "mmalloc.h" from defs.h and
moves it to the files that actually use it.
Long term mmalloc is, apparently, ment to go away. In the mean time
this helps to keep it under control.
I've tried a build/test with/with out --with-mmalloc.
I'll check it in in a few days if no one comments.
enjoy,
Andrew
2001-12-02 Andrew Cagney <ac131313@redhat.com>
* defs.h: Do not include "mmalloc.h".
(mcalloc, mmalloc, mrealloc, mfree): Delete declaration.
* objfiles.c: Include "mmalloc.h".
* utils.c: Include "mmalloc.h".
(mmalloc, mfree, mrealloc, mmalloc): Make static, change PTR to
void pointer.
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.66
diff -p -r1.66 defs.h
*** defs.h 2001/12/02 02:57:13 1.66
--- defs.h 2001/12/03 21:58:29
***************
*** 59,68 ****
#include "progress.h"
- #ifdef USE_MMALLOC
- #include "mmalloc.h"
- #endif
-
/* For BFD64 and bfd_vma. */
#include "bfd.h"
--- 59,64 ----
*************** extern char *savestring (const char *, s
*** 1028,1043 ****
extern char *msavestring (void *, const char *, size_t);
extern char *mstrsave (void *, const char *);
-
- #if !defined (USE_MMALLOC)
- /* NOTE: cagney/2000-03-04: The mmalloc functions need to use PTR
- rather than void* so that they are consistent with the delcaration
- in ../mmalloc/mmalloc.h. */
- extern PTR mcalloc (PTR, size_t, size_t);
- extern PTR mmalloc (PTR, size_t);
- extern PTR mrealloc (PTR, PTR, size_t);
- extern void mfree (PTR, PTR);
- #endif
/* Robust versions of same. Throw an internal error when no memory,
guard against stray NULL arguments. */
--- 1024,1029 ----
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.18
diff -p -r1.18 objfiles.c
*** objfiles.c 2001/12/02 22:38:23 1.18
--- objfiles.c 2001/12/03 21:58:30
***************
*** 43,48 ****
--- 43,50 ----
#if defined(USE_MMALLOC) && defined(HAVE_MMAP)
+ #include "mmalloc.h"
+
static int open_existing_mapped_file (char *, long, int);
static int open_mapped_file (char *filename, long mtime, int flags);
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.51
diff -p -r1.51 utils.c
*** utils.c 2001/11/15 18:35:05 1.51
--- utils.c 2001/12/03 21:58:32
***************
*** 56,61 ****
--- 56,65 ----
#include <readline/readline.h>
+ #ifdef USE_MMALLOC
+ #include "mmalloc.h"
+ #endif
+
#ifndef MALLOC_INCOMPATIBLE
#ifdef NEED_DECLARATION_MALLOC
extern PTR malloc ();
*************** request_quit (int signo)
*** 893,906 ****
/* NOTE: These must use PTR so that their definition matches the
declaration found in "mmalloc.h". */
! PTR
! mmalloc (PTR md, size_t size)
{
return malloc (size); /* NOTE: GDB's only call to malloc() */
}
! PTR
! mrealloc (PTR md, PTR ptr, size_t size)
{
if (ptr == 0) /* Guard against old realloc's */
return mmalloc (md, size);
--- 897,910 ----
/* NOTE: These must use PTR so that their definition matches the
declaration found in "mmalloc.h". */
! static void *
! mmalloc (void *md, size_t size)
{
return malloc (size); /* NOTE: GDB's only call to malloc() */
}
! static void *
! mrealloc (void *md, void *ptr, size_t size)
{
if (ptr == 0) /* Guard against old realloc's */
return mmalloc (md, size);
*************** mrealloc (PTR md, PTR ptr, size_t size)
*** 908,921 ****
return realloc (ptr, size); /* NOTE: GDB's only call to ralloc() */
}
! PTR
! mcalloc (PTR md, size_t number, size_t size)
{
return calloc (number, size); /* NOTE: GDB's only call to calloc() */
}
! void
! mfree (PTR md, PTR ptr)
{
free (ptr); /* NOTE: GDB's only call to free() */
}
--- 912,925 ----
return realloc (ptr, size); /* NOTE: GDB's only call to ralloc() */
}
! static void *
! mcalloc (void *md, size_t number, size_t size)
{
return calloc (number, size); /* NOTE: GDB's only call to calloc() */
}
! static void
! mfree (void *md, void *ptr)
{
free (ptr); /* NOTE: GDB's only call to free() */
}