blob: fea55e230ea73a4a2d3c6eaceab5142e26613e03 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* -*- C++ -*- */
// $Id$
// MEM_SAP.i
ASYS_INLINE
ACE_MEM_SAP::~ACE_MEM_SAP (void)
{
// ACE_TRACE ("ACE_MEM_SAP::~ACE_MEM_SAP");
delete this->shm_malloc_;
}
ASYS_INLINE void *
ACE_MEM_SAP::acquire_buffer (const ssize_t size)
{
ACE_TRACE ("ACE_MEM_SAP::acquire_buffer");
if (this->shm_malloc_ == 0)
return 0; // not initialized.
size_t *lptr = ACE_static_cast (size_t *,
this->shm_malloc_->malloc (sizeof (size_t) + size));
*lptr = size;
++lptr;
return lptr;
}
ASYS_INLINE int
ACE_MEM_SAP::release_buffer (void *buf)
{
ACE_TRACE ("ACE_MEM_SAP::release_buffer");
if (this->shm_malloc_ == 0)
return -1; // not initialized.
size_t *lptr = ACE_static_cast (size_t *, buf);
--lptr;
this->shm_malloc_->free (lptr);
return 0;
}
ASYS_INLINE off_t
ACE_MEM_SAP::set_buf_len (void *buf, size_t n)
{
ACE_TRACE ("ACE_MEM_SAP::set_buf_len");
if (this->shm_malloc_ == 0)
return -1;
size_t *lptr = ACE_static_cast (size_t *, buf);
--lptr;
if (*lptr >= n)
*lptr = n;
return ((char *) lptr - (char *) this->shm_malloc_->base_addr ());
}
ASYS_INLINE ssize_t
ACE_MEM_SAP::get_buf_len (const off_t off, void *&buf)
{
#if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
ACE_TRACE ("ACE_MEM_SAP::get_buf_len");
#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
if (this->shm_malloc_ == 0)
return -1;
ssize_t retv = 0;
ACE_SEH_TRY
{
size_t *lptr = (size_t*) ((char *) this->shm_malloc_->base_addr () + off);
buf = lptr + 1;
retv = *lptr;
}
ACE_SEH_EXCEPT (this->shm_malloc_->memory_pool ().seh_selector (GetExceptionInformation ()))
{
}
return retv;
}
ASYS_INLINE int
ACE_MEM_SAP::remove (void)
{
ACE_TRACE ("ACE_MEM_SAP::remove");
return close_shm_malloc (1);
}
|