Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!watserv1!watdragon!rose!ccplumb
From: ccplumb@rose.uwaterloo.ca (Colin Plumb)
Subject: SetFont(rp, &MyFont) eats 24 bytes of fast memory - why?
Message-ID: <1991Mar20.220218.25195@watdragon.waterloo.edu>
Sender: daemon@watdragon.waterloo.edu (Owner of Many System Processes)
Organization: University of Waterloo
Date: Wed, 20 Mar 1991 22:02:18 GMT
Lines: 33

I'm trying to change some text-rendering code to use the system libraries
instead of blitting pieces of a private bitmap.  So I made a TextFont
structure wrapper, set it to point to the bitmap, made a tf_CharLoc
array, etc.  Then I did SetFont(rp, &Myfont) and used Text(), and
lo! it works.

However, my code was eating 24 bytes of fast memory per run and I was
going crazy trying to find it.  Eventually I single-stepped through
with a memory watcher and found that the SetFont() call was allocating
24 bytes of fast memory, and following it with things like
SetFont(rp, NULL); or SetFont(rp, old_value_of_rp_Font); did not
subsequently free this memory.  Neither did closing the old font, or
anything else I've been able to think of.

Now, my private TextFont structure contains a dummy tf_Message, which
I initialise to all zeros.  (I've also tried initialising it to all
bogus values like 0xDEADBEEF, but it doesn't change anything.)  SetFont()
sets the mn_ReplyPort to something.  It has no name, its ln_Pred points
to MyFont, and the initial value I stuff in mn_ReplyPort gets copied to
it at an offset of 8, stomping on the ln_Type, ln_Pri and half of
ln_Name.  Its successor node is full of zeros.

(BTW, sizeof(struct MsgPort) = 34.  I'm losing 24.)

I haven't the faintest f%$^%^ing idea what this is doing (the includes
say "reply port for font removal", and I can't find anything further),
but would like it to go away.  Someone suggested I live with 24 bytes of
leakage per run.  I'm vaguely dissatisfied with this solution.

Can anyone tell me what is going on and what is the right way to create a
private TextFont structure?
-- 
	-Colin
