- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shared Memory problem (pointer arithmetic)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
09-24-2013 03:15 PM
09-24-2013 03:15 PM
Re: Shared Memory Problem
On further reflection (and before anyone else says it :-) it's not garbage, it's adding 48 * the size of the structure, which is expected. I just wasn't looking at it that way. Casting the pointer as a long is what made it work.
Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013 09:55 PM
09-24-2013 09:55 PM
Re: Shared Memory problem (pointer arithmetic)
>It was a very obscure little pointer arithmetic problem. Seems that if you have a pointer to a structure and add an integer to it, you get garbage.
No, this is well defined by the C and C++ Standards. The result of ptoT + N is &ptoT[N] and is the same as
(T*)((char*)ptoT + N * sizeof(T)).
>Casting both the address and the int as a long fixed it.
The proper fix is to cast the pointer to a char*, then add, then cast back to the right type.
- « Previous
-
- 1
- 2
- Next »