Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!ists!yunexus!maccs!cs4g6ag From: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Newsgroups: comp.sys.ibm.pc Subject: Re: Yet Another Turbo C Question Message-ID: <260ACBF7.24350@maccs.dcss.mcmaster.ca> Date: 24 Mar 90 01:23:02 GMT References: <42900071@uicsrd.csrd.uiuc.edu> Reply-To: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Organization: McMaster University, Hamilton, Ontario Lines: 28 In article <42900071@uicsrd.csrd.uiuc.edu> dkchen@uicsrd.csrd.uiuc.edu writes: $ Recently I tried to port my program from an unix machine to my 386/20 $ running turbo/c. To my surprise, turbo/c sometimes returned ds:0000 from $ the malloc routine. Consecutive malloc will not solve this problem. $ I assume ds:0000 should be reserved as 'nil'. And printing data pointed $ by pointer with value ds:0000 actually generate (null) as output. Am I $ missing anything (such as compiler switches, etc.)? The turbo/c I used $ is version 2.0. All comment are appreciated. I believe that in the various memory models, a pointer consisting of all zeroes is used as a NULL pointer. malloc () uses NULL to indicate that it is unable to allocate the desired chunk of memory, so it sounds to me like you're using too small a memory model. Turbo C defaults to the small model (up to 64K of code and up to 64K of data); you may want to try out the compact modem (up to 64K of code and the rest of memory available for dynamically and statically allocated data). BTW, due to the 8086 family's segmented architecture, any compiler that lets you pick near or far addressing (and almost all C compilers do, since there's a difference in performance and object code size) has several different memory models available; your problem is not specific to either your 386 or to Turbo C, so others may have the same problem with different hardware and compilers. -- Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca = "\nI'm only an undergraduate!!!\n"; **************************************************************************** "So sorry, I never meant to break your heart ... but you broke mine."