reviving games/freebsd-games
clemens fischer
ino-news at spotteswoode.dnsalias.org
Tue Oct 28 05:04:02 PDT 2008
On Tue, 28 Oct 2008 11:57:15 +0100 Jurjen Middendorp wrote:
> If you do char *p = "something", you can't write to that string (it's
> a pointer into some stringtable: easy way to look at it :). You have
> to use char p[] = "something", then it's an array with enough storage
> to write to :) maybe try something like char scrollname[NUMSCROLLS][]; ?
Thank you and Martin for your very helpful comments! You have a point
there: the compiler might put the strings themselves into a read-only
table and keep only the pointers to them, as declared. I didn't think
of that. Do you happen to know what linker section gcc-4.x puts strings
into?
I thought I'd clean up that code declaring a real struct like:
struct scrollname_s {
int active;
char name[] = "...";
};
then name could stay read-only. OTOH I found numerous larn versions, so
keeping ours "compatible" might keep maintenance costs down.
-c
More information about the freebsd-questions
mailing list