blob: 30841bfdadbfe36eeee2e5cdc609bfcbb9cba407 (
plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <assert.h>
#include "database-references.h"
#include "database.h"
RefFrom::RefFrom(RefTo * refTo, SegmentRefData * data) : refTo(refTo), data(data) {
assert(refTo);
assert(data);
next = data->getRefFrom();
prev = 0;
data->setFirstRefFrom(this);
if (next)
next->prev = this;
}
RefFrom::~RefFrom() {
if (next)
next->prev = prev;
if (prev)
prev->next = next;
else
data->setFirstRefFrom(next);
}
RefTo::RefTo(absolute_ptr ptr, SegmentRefData * data, Database * database) : data(data) {
assert(database);
Segment * destSeg = database->getSegment(ptr.segment_id);
assert(destSeg);
refFrom = new RefFrom(this, destSeg->getSegmentRefData(ptr.ptr));
RefTo * t = data->getRefTo();
if (t) {
delete t;
data->setRefTo(this);
}
}
RefTo::~RefTo() {
data->setRefTo(0);
delete refFrom;
}
SegmentRefData::SegmentRefData(Uint32 ptr, Segment * seg) : ptr(ptr), seg(seg) {
seg->setSegmentRefData(ptr, this);
}
SegmentRefData::~SegmentRefData() {
seg->setSegmentRefData(ptr, 0);
}
|