Function pgrx_pg_sys::GetMemoryChunkContext
source · pub unsafe fn GetMemoryChunkContext(pointer: *mut c_void) -> MemoryContext
Expand description
Given a currently-allocated chunk of Postgres allocated memory, determine the context it belongs to.
All chunks allocated by any memory context manager are required to be preceded by the corresponding MemoryContext stored, without padding, in the preceding sizeof(void*) bytes. A currently-allocated chunk must contain a backpointer to its owning context. The backpointer is used by pfree() and repalloc() to find the context to call.
§Safety
The specified pointer
must be one allocated by Postgres (via [palloc
] and friends).
§Panics
This function will panic if pointer
is null, if it’s not properly aligned, or if the memory
it points to doesn’t have a prefix that looks like a memory context pointer