1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 ss_persobj_t *
 ss_pers_deref(ss_pers_t *pers)
 {
     SS_ENTER(ss_pers_deref, ss_persobj_tP);
     ss_persobj_t        *persobj=NULL;                  /* A pointer to the persistent object to be returned */

     SS_ASSERT(pers);
     SS_ASSERT_CLASS(pers, ss_pers_t);

     /* Make sure link is current */
     if (ss_pers_update(pers)<0) SS_ERROR(FAILED);

     /* Error conditions */
     if (SS_PERS_LINK_NULL==ss_pers_link_state(pers)) SS_ERROR_FMT(NOTFOUND, ("dereferencing a null link"));
     if (SS_PERS_LINK_RESERVED==ss_pers_link_state(pers)) SS_ERROR_FMT(CORRUPT, ("mangled object link"));
     if (SS_PERS_LINK_CLOSED==ss_pers_link_state(pers)) SS_ERROR_FMT(NOTFOUND, ("object not found"));

     /* Result */
     persobj = ss_pers_link_objptr(pers);
     SS_ASSERT(persobj);
     SS_ASSERT_CLASS(persobj, ss_persobj_t);
     SS_ASSERT(SS_MAGIC_SEQUENCE(SS_MAGIC_OF(persobj))==SS_MAGIC_SEQUENCE(SS_MAGIC_OF(pers)));

 SS_CLEANUP:
     SS_LEAVE(persobj);
 }