From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,bfe5578aefdfff6,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2002-05-29 11:38:33 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: anton@ebi.ac.uk (Anton Enright) Newsgroups: comp.unix.tru64 Subject: malloc/realloc on Compaq Tru64 Date: 29 May 2002 11:38:32 -0700 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 62.253.128.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1022697513 21809 127.0.0.1 (29 May 2002 18:38:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 29 May 2002 18:38:33 GMT Xref: archiver1.google.com comp.unix.tru64:7840 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 #include /* 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