[comp.sys.apollo] malloc and gpr_$text problem

culmer@eniac.seas.upenn.edu (Charles Culmer) (02/12/89)

I can't get gpr_$text to print character strings that were allocated
with sys5 malloc.  For example, if I read "Charles" into a statically
allocated buffer, allocate space with malloc, copy the input buffer
into the new string, and then try to print the text with gpr_$text,
I get output that looks like--

     space up-arrow space C h a r

I'm doing this on a 3000 with version 9.7 sys5.

I'm pretty sure the problem isn't a mistake or my ignorance of C and
gpr.  The same programs work fine if I use printf to print the strings.
Moreover, if I statically allocate another text buffer and copy from
the dynamically allocated buffer into the statically allocated buffer,
gpr_$text prints the string from that buffer just fine.

Thanks.



Charles W. Culmer
culmer@eniac.seas.upenn.edu      Truth, justice, and the American way.

lnz@LUCID.COM (Leonard N. Zubkoff) (02/13/89)

Have you remembered to deal with the fact that GPR_$Text requires its
string argument to be passed by reference?  If you have a char *Foo
variable rather than an array, you must call GPR_$Text as:

gpr_$text(*Foo,...).