From 5dc4e2378c5ddbd72c1c5c23dc438181594ce8af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Fri, 12 May 2000 19:45:26 -0700
Subject: [PATCH] added get_parent_storage

Rev: src/modules/Oracle/oracle.c:1.40
Rev: src/program.c:1.238
---
 src/modules/Oracle/oracle.c | 11 ++++--
 src/program.c               | 72 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/src/modules/Oracle/oracle.c b/src/modules/Oracle/oracle.c
index 81fc30a0c0..5636c3d0c6 100644
--- a/src/modules/Oracle/oracle.c
+++ b/src/modules/Oracle/oracle.c
@@ -1,5 +1,5 @@
 /*
- * $Id: oracle.c,v 1.39 2000/05/13 02:09:41 hubbe Exp $
+ * $Id: oracle.c,v 1.40 2000/05/13 02:45:26 hubbe Exp $
  *
  * Pike interface to Oracle databases.
  *
@@ -42,7 +42,7 @@
 #include <oci.h>
 #include <math.h>
 
-RCSID("$Id: oracle.c,v 1.39 2000/05/13 02:09:41 hubbe Exp $");
+RCSID("$Id: oracle.c,v 1.40 2000/05/13 02:45:26 hubbe Exp $");
 
 
 #define BLOB_FETCH_CHUNK 16384
@@ -147,7 +147,11 @@ DEFINE_MUTEX(oracle_serialization_mutex);
 #define PARENTOF(X) (X)->parent
 
 
-/* This will be moved to program.c - Hubbe */
+/* This define only exists in Pike 7.1.x, if it isn't defined
+ * we have to provide this function ourselves -Hubbe
+ */
+#ifndef IDENTIFIER_SCOPE_USED
+
 void *parent_storage(int depth)
 {
   struct inherit *inherit;
@@ -216,6 +220,7 @@ void *parent_storage(int depth)
 
   return o->storage + inherit->storage_offset;
 }
+#endif
 
 #ifdef PIKE_DEBUG
 void *check_storage(void *storage, unsigned long magic, char *prog)
diff --git a/src/program.c b/src/program.c
index b1a1c2cb75..1b553d8a86 100644
--- a/src/program.c
+++ b/src/program.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: program.c,v 1.237 2000/05/11 14:09:46 grubba Exp $");
+RCSID("$Id: program.c,v 1.238 2000/05/13 02:44:36 hubbe Exp $");
 #include "program.h"
 #include "object.h"
 #include "dynamic_buffer.h"
@@ -4102,3 +4102,73 @@ int yyexplain_not_implements(struct program *a, struct program *b, int flags)
   }
   return 1;
 }
+
+/* This will be moved to program.c - Hubbe */
+void *parent_storage(int depth)
+{
+  struct inherit *inherit;
+  struct program *p;
+  struct object *o;
+  INT32 i;
+
+  inherit=&fp->context;
+  o=fp->current_object;
+  
+  if(!o)
+    error("Current object is destructed\n");
+  
+  while(1)
+  {
+    if(inherit->parent_offset)
+    {
+      i=o->parent_identifier;
+      o=o->parent;
+      depth+=inherit->parent_offset-1;
+    }else{
+      i=inherit->parent_identifier;
+      o=inherit->parent;
+    }
+    
+    if(!o) return 0;
+    if(!(p=o->prog)) return 0;
+    
+#ifdef DEBUG_MALLOC
+    if (o->refs == 0x55555555) {
+      fprintf(stderr, "The object %p has been zapped!\n", o);
+      describe(p);
+      fatal("Object zapping detected.\n");
+    }
+    if (p->refs == 0x55555555) {
+      fprintf(stderr, "The program %p has been zapped!\n", p);
+      describe(p);
+      fprintf(stderr, "Which taken from the object %p\n", o);
+      describe(o);
+      fatal("Looks like the program %p has been zapped!\n", p);
+    }
+#endif /* DEBUG_MALLOC */
+    
+#ifdef PIKE_DEBUG
+    if(i < 0 || i > p->num_identifier_references)
+      fatal("Identifier out of range!\n");
+#endif
+    
+    inherit=INHERIT_FROM_INT(p, i);
+    
+#ifdef DEBUG_MALLOC
+    if (inherit->storage_offset == 0x55555555) {
+      fprintf(stderr, "The inherit %p has been zapped!\n", inherit);
+      debug_malloc_dump_references(inherit,0,2,0);
+      fprintf(stderr, "It was extracted from the program %p %d\n", p, i);
+      describe(p);
+      fprintf(stderr, "Which was in turn taken from the object %p\n", o);
+      describe(o);
+      fatal("Looks like the program %p has been zapped!\n", p);
+    }
+#endif /* DEBUG_MALLOC */
+    
+    if(!depth) break;
+    --depth;
+  }
+
+  return o->storage + inherit->storage_offset;
+}
-- 
GitLab