So, has anyone figured out how much code space is required
for the resource
                approach as opposed to the hard coded method?


(NOTE: All values are numbers of bytes)

For storage space: 

Assuming a string with a length of nChars, 

a hard-coded string takes nChars + 1 (null terminator) in the dynamic heap
and

a 'tSTR' resource string takes nChars + 1 (null terminator) plus one chunk
header for the chunk that the resource (8) is stored in plus one entry in
the program's DatabaseHeaderType (4). Essentially, nChars + 13 in the
storage heap.



For code:

A hard coded string is referred to directly with a pointer (4 in the dynamic
heap).

The code for loading the string (this will change given error trapping and
other techniques for using the string)

        VoidHand hString = NULL;
    
        // Get resource
        hString = DmGet1Resource('tSTR', 1000);
    
        // Do sumptin'
        //blah, blah, blah
    
        // Release resource
        DmReleaseResource(hString);

is 36 bytes (by my count) in the storage heap using Code Warrior to
dissassemble the above code + 8 bytes in the dynamic heap for hString and
pString. 

So, to summarize:

Hard code:  (nChars + 1) (storage in dynamic heap) + 4 (code in storage
heap)
Resource: (nChars + 13) (storage in storage heap) + 36 (code in storage
heap) + 8 (code in dynamic heap).

Don't forget (as pointed out before in this thread) the dynamic memory is
scarcer than storage memory. (The resource technique uses less dynamic
memory.)


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