🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.linux
Article #56121

Re: Memory Allocation Problems

#56121
From: Dimitri Maziuk
Date: Thu, 10 Apr 1997 00:00
23 lines
1383 bytes
Dan wrote:
> 
...
 
> 2) This is the one I can not fix (Electric fence found this one at a
> higher level than where the code was crashing): I am using strcpy to copy
> a string. The destination string has been allocated the right ammount of
> memory, but when it copies, I get the segmentation fault. I do have
> another way round the problem if I can not figure out why it is crashing.

Ah.  Do you declare the string as char * or as char[] ?
IIRC gcc treats char * strings as constants, or something 
like that -- see the -fwritable-strings option in gcc manpage.
If that's the case, try using char arrays instead of pointers.
BTW I think there's also string class in libg++ (or was libstdc++ ?)

-- 
Dimitri
emaziuk @ curtin.edu.au
-----------------------
What color is a chameleon on a mirror?
			( Zen koan )
Technical Details
Message-ID: <334BDCA4.1B8E8C8C@eris.dev.null>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <5iareb$i91$1@gruvel.une.edu.au> <33492BEA.830839C@eris.dev.null> <5ibtd0$13m$1@gruvel.une.edu.au> <334b85d5.0@news.topend.com.au> <5if39k$69k$1@gruvel.une.edu.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 102983,b7f2caa39b1617c0
X-Google-Attributes: gid102983,public
From: Dimitri Maziuk <dima@eris.dev.null>
Subject: Re: Memory Allocation Problems
Date: 1997/04/10
Message-ID: <334BDCA4.1B8E8C8C@eris.dev.null>
X-Deja-AN: 231863241
References: <5iareb$i91$1@gruvel.une.edu.au> <33492BEA.830839C@eris.dev.null> <5ibtd0$13m$1@gruvel.une.edu.au> <334b85d5.0@news.topend.com.au> <5if39k$69k$1@gruvel.une.edu.au>
Organization: Legion of Static Discord
Newsgroups: aus.computers.linux