diff --git a/src/modules/Oracle/oracle.c b/src/modules/Oracle/oracle.c index 81fc30a0c0687f8bcb7b08d9dabdf7edacc00fb7..5636c3d0c63e11f417bb319f3eca523af95669f7 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 b1a1c2cb75ca29a2d2bb1a4ca37e2dea23f0c8a6..1b553d8a86c750ba1ae98d5fa5ac140955c53724 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; +}