>From [EMAIL PROTECTED]:

                Note that all this means Tom McCormick's calculations for
hard coded
                strings are off: unless you're insane, the nChars + 1 bytes
that contain
                the string are in the code resource, and thus in the storage
heap, and
                there's no extra pointer involved.


I am not usually prone to insanity, but I spent all of yesterday (7+ hours)
in a sales meeting; could be an unfortunate side effect.

Code Warrior (using default settings) embeds strings just after the function
that uses them along with a null terminator (nChars + 1). All this ends up
in the code resource which is placed in the storage heap. (I called this the
dynamic heap when I wrote this yesterday. Opps! My mistake and I apologize
for the confusion.)

When you refer to this string in any code, the compiler refers to the
location of this code with a "4 byte pointer".  Upon re-inspecting my code
example that I used for my calculations, I found an LEA <offset> instruction
to refer to the string at the end of the function. I should have said the
string is referred to with a 2 byte instruction and a 2 byte offset. Right
math, wrong description. (I counted every last byte in the resource method
so I counted these four bytes to keep the playing field as level as I
could.)

So let's try again:

Hard code:  (nChars + 1) (storage in storage heap - 'code') + 4 (code in
storage heap - 'code').
Resource: (nChars + 13) (storage in storage heap - 'tSTR') + 36 (code in
storage heap - 'code') + 8 (code in dynamic heap hString and pString).

(How's that John? - Thanks for keeping me honest!)

Thomas McCormick
Centennial Technologies
7 Lopez Road
Wilmington, MA 01887
Phone: (978) 805-2147
e-mail: [EMAIL PROTECTED]

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to