Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Oct 2008 13:03:32 +0100
From:      clemens fischer <ino-news@spotteswoode.dnsalias.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: reviving games/freebsd-games
Message-ID:  <klbjt5xb52.ln2@nntp.spotteswoode.dnsalias.org>
References:  <ariht5xulu1.ln2@nntp.spotteswoode.dnsalias.org> <20081027200749.GB29814@icarus.home.lan> <20081027202219.GE2435@spotteswoode.de.eu.org> <20081028105715.GA33501@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?klbjt5xb52.ln2>