- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: malloc problem in porting HPUX 10.20 code on H...
Operating System - HP-UX
1753899
Members
7694
Online
108809
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2002 04:15 AM
тАО06-20-2002 04:15 AM
Hi all,
I have a problem in porting my HPUX 10.20 application (c code) to HPUX
11.11. Whenever there is calloc or realloc function, the application
coredumps and aborts.
I have to compile the programs using +DD64 option, as the application
uses informix objects which come pre-compiled using +DD64 option. I have
simulated the condition in one small program given below, which works on
10.20 and works on 11.11 if compiled without +DD64 option. But does not
work if compiled on 11.11 with +DD64 option.
Thanks for the help,
Suhas
cc -Aa +DD64
#define ALLOC(PTR) PTR=(struct ob *) calloc(2,sizeof(struct ob));
struct ob{
int nitin;
char kicha;
};
#include
main(){
int * ptr;
int a[16]={1,2,3,4,5,6,7,8,9,0,1,2,3,4};
struct ob *ob1;
ALLOC(ob1)
ptr=a;
ob1->nitin=10;
ob1->kicha='c';
printf("%d,%c",ob1->nitin,ob1->kicha);
}
I have a problem in porting my HPUX 10.20 application (c code) to HPUX
11.11. Whenever there is calloc or realloc function, the application
coredumps and aborts.
I have to compile the programs using +DD64 option, as the application
uses informix objects which come pre-compiled using +DD64 option. I have
simulated the condition in one small program given below, which works on
10.20 and works on 11.11 if compiled without +DD64 option. But does not
work if compiled on 11.11 with +DD64 option.
Thanks for the help,
Suhas
cc -Aa +DD64
#define ALLOC(PTR) PTR=(struct ob *) calloc(2,sizeof(struct ob));
struct ob{
int nitin;
char kicha;
};
#include
main(){
int * ptr;
int a[16]={1,2,3,4,5,6,7,8,9,0,1,2,3,4};
struct ob *ob1;
ALLOC(ob1)
ptr=a;
ob1->nitin=10;
ob1->kicha='c';
printf("%d,%c",ob1->nitin,ob1->kicha);
}
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2002 04:52 AM
тАО06-20-2002 04:52 AM
Re: malloc problem in porting HPUX 10.20 code on HPUX 11.11
You need to ADD
#include
live free or die
harry
Live Free or Die
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2002 04:56 AM
тАО06-20-2002 04:56 AM
Solution
Hi Suhas:
If you #include above the macro the program runs fine. I think the calloc function needs a prototype, or the compiler assumes it returns a 4 byte integer instead of an 8 byte pointer to void. The address after the cast to (struct ob *) is not in the process space and gives a memory access fault.
Cheers,
Dave
If you #include
Cheers,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2002 06:01 AM
тАО06-20-2002 06:01 AM
Re: malloc problem in porting HPUX 10.20 code on HPUX 11.11
The answer to this is that your code (even on 10.20) was working by accident. If you had added stdlib.h to your #includes, all would have been well.
As has already been indicated, the fundamental problem is that without a prototype, functions are assumed to be int. In the 32-bit world or the +DA32 model int and *ptr are the same size but in the +DD64 model int is 4 bytes and *ptr is 8 bytes.
As has already been indicated, the fundamental problem is that without a prototype, functions are assumed to be int. In the 32-bit world or the +DA32 model int and *ptr are the same size but in the +DD64 model int is 4 bytes and *ptr is 8 bytes.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP