[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nonrelocatable block upon startup

On Wed Mar 16, Tobias Kunze writes:
  I can't figure out how to launch my image with a nonrelocatable
  block set aside in the mac heap automatically upon startup.

  What I've been trying so far is to defvar a pointer and then wrap
  the allocation itself in an eval-when; let my sourcefile be:
The code includes 
> (defvar *pointer* nil)
>   (eval-when (:load-toplevel :compile-toplevel :execute)
>     (setf *pointer* (#_newptr 256)))

The problem is that after a save-application, *pointer* is
#<Dead Mac-Pointer ...>. 

All of the information you need is in the documentation on creating
snapshots. You'll need to free the storage allocated to *pointer*
before you do a save-application. Otherwise, you may cause
system crashes and other erratic behavior. Read about
def-load-pointers for this task.  You'll also need to re-allocate
the pointe. To do this, create a function with no arguments
(defun allocate-my-pointer ()
    (setf *pointer* (#_newPPtr 256)))
If you want to be safer, check that the pointer *pointer* is valid
and if it is, dispose the storage. The def-load-pointers macro
allocates sppace on the mac heap.  Here's how to use it to allocate
the space for *pointer*.

(def-load-pointers my-pointer  ()

If you want to remove the pointer when your program terminates,
add a function to the *lisp-clean-up-function* by pushing the function
#'remove-my-pointer onto the list.