Xref: utzoo comp.sys.mac:43734 comp.sys.mac.programmer:10986 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac,comp.sys.mac.programmer Subject: Re: Novice Programmer Question: Dynamic Memory Allocation under TC Message-ID: <33100@ucbvax.BERKELEY.EDU> Date: 8 Dec 89 00:27:10 GMT References: <24770@cup.portal.com> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Distribution: usa Organization: School of Education, UC-Berkeley Lines: 29 In article <24770@cup.portal.com> David_Anthony_Guevara@cup.portal.com writes: >My question(s) is(are): When you use malloc to create a >node (ex: head = (struct linked_list *) malloc (sizeof( ELEMENT ));) >does the memory allocated come from the stack or the application heap? Neither. malloc allocates its storage out of big blocks that it gets from the Mac operating system by doing a NewPtr() system call. This is clear from the manual. >I believe my problem is that the Mac is relocating my pointers and the >program just drops into a black hole. The mac never relocates pointers. It only relocates handles, and you can't get a handle without specifically asking for one. To debug a program, set a breakpoint at a point you _know_ it reaches. (It always reaches the beginning.) Single step, looking at data structures as appropriate, until you get to the problem. Reapeat as necessaary until you understand enough about the problem to solve it. You need to think, you need to read the manuals, and you need to be observant. > The mac is a detour in the inevitable march of mediocre computers. > drs@bnlux0.bnl.gov (David R. Stampf) --- David Phillip Oster -master of the ad hoc odd hack. Arpa: oster@dewey.soe.berkeley.edu Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu