I found some problems passing pointers to allocated memory chunks between functions
located in different segments. For example:
//#defines for multisegmentation
//Seg1 is .TEXT
//Seg2 is .SEGMENT2
#define Seg1
#define Seg2 __attribute__ ((section("SEGMENT2")))
//declariations
//func1() in .TEXT
//func2() in .SEGMENT2
void func1() Seg1;
Boolean func2(Char *str) Seg2;
//definitions
void func1(){
Boolean result;
Char *str;
str=MemPtrNew(SIZE); //str is allocated by func1()
StrCopy(str,"ciao");
func2(str); //now calling func2() with argument
//pointing to allocated memory
}
Boolean func2(Char *str){
WinPaintChars(str,StrLen(str),1,1); //doing something not
//important with str
return true;
}
In this example, when I call func2() from main() I get a runtime error, while putting
func2() in segment Seg1 (i.e. .TEXT segment...) doesn't give any error.
Why?
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/