home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!mcsun!sun4nl!nikhefh!t68
- From: t68@nikhefh.nikhef.nl (Jos Vermaseren)
- Newsgroups: comp.sys.next.programmer
- Subject: Re: Memory Allocation Error
- Message-ID: <2184@nikhefh.nikhef.nl>
- Date: 21 Jan 93 15:37:18 GMT
- References: <C16K2t.HGC@agora.rain.com>
- Organization: Nikhef-H, Amsterdam (the Netherlands).
- Lines: 30
-
- In article <C16K2t.HGC@agora.rain.com>, bobb@agora.rain.com (Bob Beauchemin) writes:
- >
- > I'm having a problem with the NeXT 2.1 compiler and wonder if anyone else
- > has experienced it. Code that compiles OK and works on other platforms
- > fails on the NeXT. The error messages (at program execution) are:
- >
- The argument that it runs on other platforms is not so good. Many old style
- UNIX programmers messed up int's and pointers freely.....
-
- I have had similar problems with free when you give it a pointer that
- you did not get from malloc before (like a NULL pointer). It can result
- in very erratic behaviour after the (illegal) freeing.
- It is just one of those things....
- The standard says what free should do when everything is swell but
- of course the question is what it should do when things are wrong. Standards
- rarely specify. You could crash the program, continue execution which a
- poisoned system (what NeXT does) or when you manage to set up malloc and
- free in such a way that nothing gets poisoned just keep running
- (like many other systems do).
- Unless there is a real programming error inside Mach, I guess formally you
- cannot blame NeXT too much. You should have a good look inside your program
- and make sure that each pointer that is freed is allowed to be freed.
- A little macro like
- #define MyFree(x) if ( x != NULL ) { free(x); x = NULL; }
- can work miracles. You could sneak in an else with an error message if you
- want to see whether you try to free the same thing twice.
- Of course it would be nice if the NeXT would crash the program rather than
- continue running..... Or would it? Maybe a good error message?
-
- Jos Vermaseren
-