You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Currently, jemalloc stores the object pointer and the size of the allocation in R-tree and, by using sallocx(obj_pointer), I can retrieve the size of the allocation. However, I want to retrieve the object_pointer and the size of allocation using an internal pointer. What I meant by an internal pointer is that: a pointer that points anywhere in the body of the heap-allocated object i.e.
object_pointer( or base_pointer) < internal_pointer < (object_pointer + size_of_allocation). For instance,
typedef struct FOO{
char a;
int arr[20];
} foo;
void *obj_ptr = malloc(sizeof(foo)); //Object or base pointer
void *internal_ptr = (obj_ptr + 2); // Internal pointer
assert( (obj_ptr < internal_ptr) && (internal_ptr < (obj_ptr + sizeof(foo))) ); // condition for a valid internal ptr
Now, if I have any valid internal pointer, I need to get its corresponding object pointer and size of allocation. Since jemalloc already stores all the necessary information, instead of maintaining a saperate data structure, I was thinking to add some new functions for querying the R-Tree; Something similar to rtree_leaf_elm_lookup and rtree_leaf_elm_lookup_hard but with a minor change that during tree lookup instead of if (leaf->key == input_key) it should be if(leaf->key < input_key && input_key < (leaf->key + leaf->size) ). But I'm not sure if these changes will suffice and would really appreciate any insights on this method or any alternative ways of achieving the above objective.
Thanks and Regards,
Udit Agarwal
The text was updated successfully, but these errors were encountered:
Hello,
Currently, jemalloc stores the object pointer and the size of the allocation in R-tree and, by using sallocx(obj_pointer), I can retrieve the size of the allocation. However, I want to retrieve the object_pointer and the size of allocation using an internal pointer. What I meant by an internal pointer is that: a pointer that points anywhere in the body of the heap-allocated object i.e.
object_pointer( or base_pointer) < internal_pointer < (object_pointer + size_of_allocation). For instance,
Now, if I have any valid internal pointer, I need to get its corresponding object pointer and size of allocation. Since jemalloc already stores all the necessary information, instead of maintaining a saperate data structure, I was thinking to add some new functions for querying the R-Tree; Something similar to rtree_leaf_elm_lookup and rtree_leaf_elm_lookup_hard but with a minor change that during tree lookup instead of
if (leaf->key == input_key)
it should beif(leaf->key < input_key && input_key < (leaf->key + leaf->size) )
. But I'm not sure if these changes will suffice and would really appreciate any insights on this method or any alternative ways of achieving the above objective.Thanks and Regards,
Udit Agarwal
The text was updated successfully, but these errors were encountered: