shared storage for string literals?

Sean Eric Fagan sef at kithrup.COM
Thu May 30 08:01:52 AEST 1991


In article <16293 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>>Question: can non-identical substrings share storage if one is a substring
>>of the other, and they share a common "tail"?
>Sure.  The standard doesn't allow a strictly conforming program to modify
>string literals, so this would be a safe implementation practice, and I
>would be greatly surprised if no C implementation were doing this.

And that's what the old program, xstr, would do for you.  (Well, they were
still data, but it would set things up such that "World!" and "Hello,
World!" shared some storage.  At least the version I had did 8-))

-- 
Sean Eric Fagan  | "I made the universe, but please don't blame me for it;
sef at kithrup.COM  |  I had a bellyache at the time."
-----------------+           -- The Turtle (Stephen King, _It_)
Any opinions expressed are my own, and generally unpopular with others.



More information about the Comp.lang.c mailing list