Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: anton@ebi.ac.uk (Anton Enright)
Subject: malloc/realloc on Compaq Tru64
Date: 29 May 2002 11:38:32 -0700	[thread overview]
Message-ID: <d91b7926.0205291038.632c29a0@posting.google.com> (raw)

Hi Everyone,

Forgive my ignorance here, I'm still a pretty poor C programmer :)

I've got an application that I've written in C to run on multiple
platforms.
On Compaq T64 UNIX, when I reallocate memory it seems to take allocate
twice as much memory as I expect, and observe on other platforms (eg.
solaris).

The initial memory allocation with calloc is fine, and seems to work
exactly the same on all machines I've tried (64bit and 32bit).
Eventually
I need to reallocate memory so I double the size of an array with
realloc, on
solaris machines this works fine, but the realloc on T64 seems to use
twice as much memory as on other machines....

Can someone tell me what I'm doing wrong ?, I just want to make this
code consistent across platforms....

I'm sure this is some 64bit thing which I'm not doing right..

Heres a stripped example of what I'm doing

#include <stdio.h>
#include <stdlib.h>

/* Here's the basic struct I'm working with */
struct hit_struct{
                 unsigned char protein1[30];
                 unsigned char protein2[30];
                 unsigned char evalue1;
                 unsigned char evalue2;
                 };
int main(void)
        {
        /* Declare the variable anton */
        struct hit_struct *anton;
  
        /* Allocate an array of 100000 antons */
        anton=(struct hit_struct *) calloc(100000,sizeof(struct
hit_struct));
        
        /* Reallocate and double the size of the array */
        anton=(struct hit_struct *) realloc(anton,200000*sizeof(struct
hit_struct));
        }

When this code runs on different machines, it appears to use twice as
much memory as the initial allocation..

Any help appreciated!

Thanks

Anton


             reply	other threads:[~2002-05-29 18:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-29 18:38 Anton Enright [this message]
2003-04-08 13:26 ` malloc/realloc on Compaq Tru64 BHa
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox