- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am using TBB to allocate memory for C structures and same is exposedto Java using JNI. The pointers becomes Java integers (which actually represents the pointers in native layer).Ihave following doubts.
1. In Java an integer is a32 bit signed value always. So can I restrict the address range of TBB allocation so thatit will never exceed the range 2^31 - excluding the sign bit.
2.From Java,now user can pass a random integer which will be considered as a pointer in native layer.
Does TBB provide a mechanism to check a particularvalueagainst theinternalmemory address range (block) and tellthe passed invalue isa valid pointer or not.
Thank you.
Zooli
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My requirement is slightly different. The passed in pointer can point to anything within a allocated memory block.
i.e char* pMem = (char*) scalable_malloc(1024);
Then I want something like this :
"isValid(pMem+ 100)" should return true and "isValid (pMem + 1030)" should return false.
This can be achieved by some book keeping inside my application. But I want to know if there is any built in functionality to know this.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On the other hand, if you don't know what you're holding, what would bethe meaning of such a query in a multithreaded application?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Of course , there can be valid reasons. If you read my original question completely, it is about exposing native pointer to Java. Mine is a native library. So a java user can be be mischievous (but often by mistake)to pass a random integer to native layer as valid handle. Without such a mechanism, you cannot trust such a value. This is true for native applications also. But there compiler assists to some extend.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page