home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mdcbbs!mdcbbs.com!mackintosh
- Newsgroups: comp.lang.c
- Subject: Re: malloc causes a segmentation violation!?
- Message-ID: <1992Aug19.175942.2510@mdcbbs.com>
- From: mackintosh@mdcbbs.com (Alasdair Mackintosh)
- Date: 19 Aug 92 17:59:41 PDT
- References: <1992Aug18.143135.6259@cc.tut.fi>
- Distribution: world
- Organization: M&E (Division of EDS), Cypress CA
- Nntp-Posting-Host: devhpp4
- Lines: 20
-
- In article <1992Aug18.143135.6259@cc.tut.fi>, mn87504@cs.tut.fi (Naatula Mika) writes:
-
- |> My program uses a lot of dynamic memory allocation, but I am quite
- |> sure that there is no bugs in my code. I have spent two days checking
- |> out the memory allocation of this program.
-
- You might want to look for code along the lines of:
-
- char *new_string = malloc( strlen( old_string ) );
-
- This should, of course, be:
-
- char *new_string = malloc( strlen( old_string ) +1 );
- --
- ===============================================================================
- Alasdair Mackintosh mackintosh@vxd.mdcbbs.com
- Unigraphics Division (714) 952-5698
- Electronic Data Systems 10824 Hope St, Cypress CA
-
-
-