dvmUnlockMutex(&pHdr->lock);
}
+/*
+ * Determine if [start, start+length) is contained in the in-use area of
+ * a single LinearAlloc. The full set of linear allocators is scanned.
+ *
+ * [ Since we currently only have one region, this is pretty simple. In
+ * the future we'll need to traverse a table of class loaders. ]
+ */
+bool dvmLinearAllocContains(void* start, size_t length)
+{
+ LinearAllocHdr* pHdr = getHeader(NULL);
+
+ if (pHdr == NULL)
+ return false;
+
+ return (char*) start >= pHdr->mapAddr &&
+ ((char*)start + length) <= (pHdr->mapAddr + pHdr->curOffset);
+}
+
*/
void dvmLinearAllocDump(Object* classLoader);
+/*
+ * Determine if [start, start+length) is contained in the in-use area of
+ * a single LinearAlloc. The full set of linear allocators is scanned.
+ */
+bool dvmLinearAllocContains(void* start, size_t length);
+
#endif /*_DALVIK_LINEARALLOC*/
char* str = dvmLinearStrdup(NULL, "This is a test!");
LOGI("GOT: '%s'\n", str);
+ /* try to check the bounds; allocator may round allocation size up */
+ fiddle = dvmLinearAlloc(NULL, 12);
+ LOGI("Should be 1: %d\n", dvmLinearAllocContains(fiddle, 12));
+ LOGI("Should be 0: %d\n", dvmLinearAllocContains(fiddle, 13));
+ LOGI("Should be 0: %d\n", dvmLinearAllocContains(fiddle - 128*1024, 1));
+
dvmLinearAllocDump(NULL);
dvmLinearFree(NULL, str);
}