[comp.sys.hp] Malloc Internal structure

mahesh@cs.fau.edu (Mahesh Neelakanta) (11/13/90)

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.
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
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 

bailey@math-cs.kent.edu (Jeff Bailey) (11/13/90)

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)      <bailey@mcs.kent.edu>
Department of Mathematics and Computer Science
Kent State University
Kent - OH 44242

rob@modus.sublink.ORG (Roberto O. Buratti) (11/14/90)

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.
> 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

[ more deleted ]

> 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.

I have no original malloc sources, sorry if can't help this way.
I developed a malloc package ({m,c,re}alloc/free) that runs considerably
better than both libc.a and libmalloc.a, that is, it is faster and more
efficient in terms of user available space. The library runs OK under HP-UX
and SCO-ODT (BTW what kind of problems did you find with HP-UX malloc?).
Should you find this of any help, I can post the sources on the net.

Bye.
Rob
-- 
  _ _           __             Via Aleardo Aleardi, 12 - 20154 Milano (Italy)
 | | | _  _|   (__             PHONE : +39 2 3315328 FAX: +39 2 3315778
 | | |(_)(_||_|___) Srl        E-MAIL: rob@modus.sublink.ORG
______________________________ Software & Services for Advertising & Marketing