Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created February 3, 2010 01:45
Show Gist options
  • Save methodmissing/293251 to your computer and use it in GitHub Desktop.
Save methodmissing/293251 to your computer and use it in GitHub Desktop.
static inline int
is_pointer_to_heap(ptr)
void *ptr;
{
RVALUE *p = RANY(ptr);
struct heaps_slot *heap;
if (p < lomem || p > himem || (VALUE)p % sizeof(RVALUE)) return Qfalse;
/* check if p looks like a pointer */
heap = heaps+heaps_used;
while (--heap >= heaps)
if (p >= heap->slot && p < heap->slot + heap->limit)
return Qtrue;
return Qfalse;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment