Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!neoucom!mcs.kent.edu!news From: bailey@math-cs.kent.edu (Jeff Bailey) Newsgroups: comp.sys.hp Subject: Re: Malloc Internal structure Message-ID: <1990Nov13.070007.6845@mcs.kent.edu> Date: 13 Nov 90 07:00:07 GMT References: <1990Nov13.051452.21908@cs.fau.edu> Sender: news@mcs.kent.edu (News Administrator) Reply-To: bailey@mcs.kent.edu Distribution: comp Organization: Computer Science Dept., Kent State Univ. Lines: 53 In article <1990Nov13.051452.21908@cs.fau.edu>, mahesh@cs.fau.edu (Mahesh Neelakanta) writes: > Greetings again, I'm back with another question :-) > > I have X11R4 Compiled with gcc 1.37.1 and have it working nicely. The > only problem is that sometimes when I compile X apps from expo or somewhere > else, the executable exits saying realloc() could not find anymore memory. I believe you need to edit hp.cf and include the following line: #define MALLOC_0_RETURNS_NULL It may already be there as a comment (I can't remember, it's been a while). The problem is that if you try to malloc 0 bytes under 7.0 it returns NULL instead of allocating a block of memory 0 bytes long and returning a pointer to it. > So, I kinda wrote a realloc() that just malloc'd the memory needed and copied > the original contents over to the new memory. The problem is that I need > to know the size of the original memory. From what I've read (in K&R and > soem other books) malloc stores this info before the actual memory that > we use starts, i.e: > > ------------------------------ > | | ....... > ------------------------------ > ^^^^^^^^^^^^^ ^^^^^^^^^^^^^ > Memory info User memory (what malloc() returns a ptr to) > > Right? Well, what is the structure of the memory info block for hp-ux This is a very non-portable and dangerous way of fixing things. Even if you got it to work HP could (and has the right to) change the implementation at any time. I think the #define above should fix things up though. Then again maybe you really are out of memory :-) > 7.0 (for s300's)? I do not have source access so I am asking the net. > Please reply via E-Mail or posting(If you think others will benefit > form this). BTW anyone else had problems with malloc under hp-ux? I've > tried both versions of malloc (one in libc.a and the libmalloc.a) and > both give me problems. Thanks again all you folks in net-space. > > Mahesh Neelakanta Internet: mahesh@cs.fau.edu > Undergrad Student (CS) mahesh@acc.fau.edu > (407) 367-3981 Bitnet: mahesh@fauvax > > Danger Past, God Forgotten. - Tamil Proverb --------------------------------------------------------------------- Jeff Bailey (JRB71) (System Administrator) Department of Mathematics and Computer Science Kent State University Kent - OH 44242