Added dvmLinearAllocContains().
diff --git a/vm/LinearAlloc.c b/vm/LinearAlloc.c
index 84bb103..5863fb0 100644
--- a/vm/LinearAlloc.c
+++ b/vm/LinearAlloc.c
@@ -688,3 +688,21 @@
     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);
+}
+
diff --git a/vm/LinearAlloc.h b/vm/LinearAlloc.h
index 9c1d096..c9a5c08 100644
--- a/vm/LinearAlloc.h
+++ b/vm/LinearAlloc.h
@@ -112,4 +112,10 @@
  */
 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*/
diff --git a/vm/oo/Class.c b/vm/oo/Class.c
index 330c381..23ffb0b 100644
--- a/vm/oo/Class.c
+++ b/vm/oo/Class.c
@@ -271,6 +271,12 @@
     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);
 }