Please forgive me if I'm being thick...

Can you take a pointer to a database record, increment the pointer, cast the pointer 
as a new pointer to a different type, and de-reference the new pointer (with the 
assumption that there is enough room within the allocated database record to 
accommodate the increments and cast)?

For instance:

typedef struct {
Int16   m;
} TypeA;

typedef struct {
Int16   n;
} TypeB;

VoidHand        vHand;
TypeA           *aPtr;
TypeB           *bPtr, bStruct;
Int16           x;

vHand = DmNewRecord(someOpenDB, dmMaxRecordIndex, sizeof(TypeA) + sizeof(TypeB));
aPtr = MemHandleLock(vHand);
bPtr = (TypeB*)(aPtr + 1);
x = bPtr->n;

The LAST statement is the one I'm curious about - should it work?  I know I didn't 
initialize the data in the record or check the return values from the functions and 
that I'm trying to store some unknown value in "x".  I know that I CAN do the 
following:

MemMove(&bStruct, aPtr + 1, sizeof(TypeB));

Thanks

trib
--------------------------------------------------
David Tribble, INRI Hawaii
(808) 625 2118 (v)  (808) 625 6315 (f)

Reply via email to