* mmalloc.h (struct mdesc): Add FIXME comments to point out the
authorFred Fish <fnf@specifix.com>
Tue, 30 Jun 1992 23:45:42 +0000 (23:45 +0000)
committerFred Fish <fnf@specifix.com>
Tue, 30 Jun 1992 23:45:42 +0000 (23:45 +0000)
need to save some data on a per-process basis for mapped regions
that are shared.
* attach.c (reuse):  Update the morecore field for reused mapped
regions to be correct for the current process.

mmalloc/ChangeLog
mmalloc/attach.c

index d40444bee2750a47c41a25e8d21aaf4f71ddb83f..adca17c69b4b15fa28a4ba807535bb54a984e62f 100644 (file)
@@ -1,3 +1,11 @@
+Tue Jun 30 16:44:41 1992  Fred Fish  (fnf@cygnus.com)
+
+       * mmalloc.h (struct mdesc):  Add FIXME comments to point out the
+       need to save some data on a per-process basis for mapped regions
+       that are shared.
+       * attach.c (reuse):  Update the morecore field for reused mapped
+       regions to be correct for the current process.
+
 Mon Jun 29 10:45:25 1992  Fred Fish  (fnf at cygnus.com)
 
        * mmtrace.c:  Lint.
index 44fff4f0707d729754b39e9e99df9f7f5dca0656..fcfb77255e2847e64ce600c705ec6abb5eb47ae6 100644 (file)
@@ -21,12 +21,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <string.h>
 #include "mmalloc.h"
 
 #ifndef SEEK_SET
 #define SEEK_SET 0
 #endif
 
+
+#if defined(HAVE_MMAP)
+
 /* Forward declarations/prototypes for local functions */
 
 static struct mdesc *reuse PARAMS ((int));
@@ -62,9 +66,6 @@ static struct mdesc *reuse PARAMS ((int));
 
    On failure returns NULL. */
 
-
-#if defined(HAVE_MMAP)
-
 PTR
 mmalloc_attach (fd, baseaddr)
   int fd;
@@ -100,8 +101,8 @@ mmalloc_attach (fd, baseaddr)
      then initialize the fields that we know values for. */
 
   mdp = &mtemp;
-  memset ((char *) mdp, 0, sizeof (mtemp));
-  strncpy (mdp -> magic, MMALLOC_MAGIC, MMALLOC_MAGIC_SIZE);
+  (void) memset ((char *) mdp, 0, sizeof (mtemp));
+  (void) strncpy (mdp -> magic, MMALLOC_MAGIC, MMALLOC_MAGIC_SIZE);
   mdp -> headersize = sizeof (mtemp);
   mdp -> version = MMALLOC_VERSION;
   mdp -> morecore = __mmalloc_mmap_morecore;
@@ -130,7 +131,7 @@ mmalloc_attach (fd, baseaddr)
 
   if ((mbase = mdp -> morecore (mdp, sizeof (mtemp))) != NULL)
     {
-      memcpy (mbase, mdp, sizeof (mtemp));
+      (void) memcpy (mbase, mdp, sizeof (mtemp));
       mdp = (struct mdesc *) mbase;
     }
   else
@@ -155,6 +156,11 @@ mmalloc_attach (fd, baseaddr)
    after we've switched over to using the mapped in malloc descriptor 
    rather than the temporary one on the stack.
 
+   Once we've switched over to using the mapped in malloc descriptor, we
+   have to update the pointer to the morecore function, since it almost
+   certainly will be at a different address if the process reusing the
+   mapped region is from a different executable.
+
    Also note that if the heap being remapped previously used the mmcheck()
    routines, we need to update the hooks since their target functions
    will have certainly moved if the executable has changed in any way.
@@ -181,6 +187,7 @@ reuse (fd)
        {
          mdp = (struct mdesc *) mtemp.base;
          mdp -> fd = fd;
+         mdp -> morecore = __mmalloc_mmap_morecore;
          if (mdp -> mfree_hook != NULL)
            {
              (void) mmcheck ((PTR) mdp, (void (*) PARAMS ((void))) NULL);
@@ -196,6 +203,7 @@ reuse (fd)
    to link to, but trying to initialize access to an mmap'd managed region
    always fails. */
 
+/* ARGSUSED */
 PTR
 mmalloc_attach (fd, baseaddr)
   int fd;
This page took 0.028417 seconds and 4 git commands to generate.