home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!bgsuvax!uoft02.utoledo.edu!jupiter!mneylon
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: HELP: malloc() and system dependancy
- Message-ID: <1993Jan11.144745.999@uoft02.utoledo.edu>
- From: mneylon@jupiter.cse.utoledo.edu (Michael Neylon)
- Date: 11 Jan 93 14:47:44 EST
- References: <C0p18n.DML@unx.sas.com>
- Nntp-Posting-Host: jupiter.cse.utoledo.edu
- Lines: 55
-
- walker@twix.unx.sas.com (Doug Walker) writes:
- :
- : In article <1993Jan10.203944.979@uoft02.utoledo.edu>, mneylon@jupiter.cse.utoledo.edu (Michael Neylon) writes:
- : |> My friend and I are working together on producing a flashcard program. He
- : |> has SAS/C 6.0, I have 6.1. Today, he gave me some code and a executable.
- : |> The output seems to work fine on his machine. However, when I try to run
- : |> the same executable, there is some memory conflict cause the font gets all
- : |> screwed up.
- : |>
- : |> I figure it is a malloc() call in his program. He has defined it safely
- : |> according to standards. Now, is malloc() safe to use on any system?
- : |>
- : |> He has a 2000 w/ 2.1, very little in the way of commodities ( a screen
- : |> blanker is all). I have a 500 w/ 2.1, and lots of extra programs at the top,
- : |> including Nickprefs, CopperPrefs, TM2.0, ToolsDaemon 2.0b, MFR, ASwarm3
- : |> MagIcon, and use csh for the shell.
- :
- : malloc() is totally safe on any system. Why do you suspect it of
- : causing the problem? Memory-trashing bugs often exhibit wildly
- : different behavior on different machines.
- :
- : If you suspect a memory trash, I recommend using the memlib utility
- : routines found in the SC:EXTRAS/MEMLIB drawer to help track it
- : down.
- :
- Well, now my friend is getting the same problem. The basic struct of the
- program is this...
-
- struct card {
- char a[40];
- char q[40];
- int flags;
- };
-
- main() {
- struct card *ccp;
-
- ...
-
- if((ccp=malloc(deck_size()*sizeof(struct card)))==NULL) exit(1);
-
- ...Fill ccp[] array
- ...Read back ccp[] array
-
- free(ccp);
- }
-
- It seems that the memory gets trashed at some point after allocation, because
- we have verified that the file is read properly, but otherwise we have no clue.
-
- --
- Michael Neylon aka Masem the Great and Almighty Thermodynamics GOD!
- // | Senior, Chemical Engineering, Univ. of Toledo
- \\ // Only the | Summer Intern, NASA Lewis Research Center
- \ \X/ AMIGA! | mneylon@jupiter.cse.utoledo.edu /
-