Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!utfyzx!sq!msb From: msb@sq.UUCP Newsgroups: comp.arch,comp.lang.c Subject: Re: String Handling -- strcpy() and shared memory Message-ID: <1987Apr20.125657.6693@sq.uucp> Date: Mon, 20-Apr-87 12:56:57 EST Article-I.D.: sq.1987Apr20.125657.6693 Posted: Mon Apr 20 12:56:57 1987 Date-Received: Wed, 22-Apr-87 03:26:48 EST References: <15915@sun.uucp> <1987Apr1.121330.15976@sq.uucp> <573@csun.UUCP> Reply-To: msb@sq.UUCP (Mark Brader) Organization: SoftQuad Inc., Toronto Lines: 31 Xref: utgpu comp.arch:971 comp.lang.c:1736 Checksum: 38254 Mike Stump (aeusemrs@csun.UUCP) writes: > Well, not to pick on you, but, have you ever done ANY programming using shared > memory, succesfully, and bug free? Just enough to be aware of the problems involved. > Tell me, how would you do something like a > strcpy in such an environment? char *strcpy (to, from) register char *to, *from; { char *start = to; while ((*to++ = *from++)) != 0) ; return start; } But this would be with the understanding that a copy of a string in the process of being changed might produce garbage; any process using strcpy() to lengthen a string would be expected to plant a suitably located NUL first. (Not necessarily at strlen(from)+to; at to+sizeof(tobuffer)-1 would do.) If this isn't sufficient protection, then semaphores or the like become appropriate. > You should just say: ``No one should use shared memory, unless > he/she knows what they are doing'' Well, I can certainly agree with that. Mark Brader