BOSS
6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
AutoEnlargeBuffer.h
Go to the documentation of this file.
1
#ifndef AUTO_ENLARGE_BUFFER_H
2
#define AUTO_ENLARGE_BUFFER_H
3
4
#include <stdlib.h>
5
#include <string.h>
//for memcpy
6
7
class
AutoEnlargeBuffer
8
{
9
public :
10
11
inline
AutoEnlargeBuffer
(
int
size
= 128*1024);
12
13
inline
~AutoEnlargeBuffer
();
14
15
inline
void
copy
(
void
*src,
int
size
);
16
17
inline
int
size
() {
return
m_size; }
18
inline
void
*
data
() {
return
m_buffer; }
19
20
21
private
:
22
23
int
m_SIZE;
24
int
m_size;
25
void
* m_buffer;
26
};
27
28
inline
AutoEnlargeBuffer::AutoEnlargeBuffer
(
int
size)
29
: m_SIZE( size ),
30
m_size( 0 )
31
{
32
m_buffer = malloc(
size
);
33
}
34
35
inline
AutoEnlargeBuffer::~AutoEnlargeBuffer
()
36
{
37
free( m_buffer );
38
}
39
40
inline
void
AutoEnlargeBuffer::copy
(
void
*src,
int
size)
41
{
42
if
(
size
> m_SIZE ) {
43
do
{
44
m_SIZE *= 2;
45
}
46
while
(
size
> m_SIZE );
47
48
free( m_buffer );
49
m_buffer = malloc(m_SIZE);
50
}
51
52
m_size =
size
;
53
memcpy(m_buffer, src,
size
);
54
}
55
56
#endif
private
#define private
Definition:
RootEventData_rootcint.cxx:10
AutoEnlargeBuffer
Definition:
AutoEnlargeBuffer.h:8
AutoEnlargeBuffer::~AutoEnlargeBuffer
~AutoEnlargeBuffer()
Definition:
AutoEnlargeBuffer.h:35
AutoEnlargeBuffer::size
int size()
Definition:
AutoEnlargeBuffer.h:17
AutoEnlargeBuffer::AutoEnlargeBuffer
AutoEnlargeBuffer(int size=128 *1024)
Definition:
AutoEnlargeBuffer.h:28
AutoEnlargeBuffer::copy
void copy(void *src, int size)
Definition:
AutoEnlargeBuffer.h:40
AutoEnlargeBuffer::data
void * data()
Definition:
AutoEnlargeBuffer.h:18
source
DistBoss
DistBossUtil
DistBossUtil-00-00-02
DistBossUtil
AutoEnlargeBuffer.h
Generated by
1.9.6