diff --git a/src/ChangeLog b/src/ChangeLog
index 94a6ec59062a675c4a3ba0f23e6fa3b7a89049db..9c1a88772248707c5a845259220360fb428f8bef 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+Sun Mar 23 14:09:18 1997  Fredrik Hubinette  <hubbe@cytocin.hubbe.net>
+
+	* program.c (get_storage): new function
+
 Mon Mar 17 14:14:34 1997  Fredrik Hubinette  <hubbe@cytocin.hubbe.net>
 
 	* peep.c (insopt): line numbering info bug fixed
diff --git a/src/program.c b/src/program.c
index 925eeb0e2b5ca2cef0346659beee6d0a56ceb2de..2a1c1322994af15cef7e3e8bfcf31fa63f104699 100644
--- a/src/program.c
+++ b/src/program.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: program.c,v 1.28 1997/03/17 03:04:43 hubbe Exp $");
+RCSID("$Id: program.c,v 1.29 1997/03/23 22:23:52 hubbe Exp $");
 #include "program.h"
 #include "object.h"
 #include "dynamic_buffer.h"
@@ -1696,3 +1696,43 @@ void pop_locals()
   local_variables=l;
   /* insert check if ( local->next == parent locals ) here */
 }
+
+
+#define GET_STORAGE_CACHE_SIZE 1024
+static struct get_storage_cache
+{
+  INT32 oid, pid, offset;
+} get_storage_cache[GET_STORAGE_CACHE_SIZE];
+
+char *get_storage(struct object *o, struct program *p)
+{
+  INT32 oid,pid, offset;
+  unsigned INT32 hval;
+  if(!o->prog) return 0;
+  oid=o->prog->id;
+  pid=p->id;
+  hval=(oid*9248339 + pid) % GET_STORAGE_CACHE_SIZE;
+  if(get_storage_cache[hval].oid == oid &&
+     get_storage_cache[hval].pid == pid)
+  {
+    offset=get_storage_cache[hval].offset;
+  }else{
+    INT32 e;
+    offset=-1;
+    for(e=0;e<o->prog->num_inherits;e++)
+    {
+      if(o->prog->inherits[e].prog==p)
+      {
+	offset=o->prog->inherits[e].storage_offset;
+	break;
+      }
+    }
+
+    get_storage_cache[hval].oid=oid;
+    get_storage_cache[hval].pid=pid;
+    get_storage_cache[hval].offset=offset;
+  }
+
+  if(offset == -1) return 0;
+  return o->storage + offset;
+}
diff --git a/src/program.h b/src/program.h
index 326913e0413961ee39096aeac6a49af650f7ba43..900c03156d0f7bc5fc0178566c14a7c201c64a48 100644
--- a/src/program.h
+++ b/src/program.h
@@ -251,6 +251,7 @@ void gc_free_all_unreferenced_programs();
 void count_memory_in_programs(INT32 *num_, INT32 *size_);
 void push_locals();
 void pop_locals();
+char *get_storage(struct object *o, struct program *p);
 /* Prototypes end here */