1 /****************************************************************************
2 * Copyright (C) 2006-2008 by Jason Ansel *
3 * jansel@csail.mit.edu *
4 * *
5 * This file is part of the JALIB module of DMTCP (DMTCP:dmtcp/jalib). *
6 * *
7 * DMTCP:dmtcp/jalib is free software: you can redistribute it and/or *
8 * modify it under the terms of the GNU Lesser General Public License as *
9 * published by the Free Software Foundation, either version 3 of the *
10 * License, or (at your option) any later version. *
11 * *
12 * DMTCP:dmtcp/src is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Lesser General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with DMTCP:dmtcp/src. If not, see *
19 * <http://www.gnu.org/licenses/>. *
20 ****************************************************************************/
21
22 #include "jbuffer.h"
23 #include "jassert.h"
24
25 jalib::JBuffer::JBuffer ( int size )
26 :_buffer ( new char[size] )
27 ,_size ( size )
|
Event tainted_data_sink_lv_call: |
Passing tainted variable "size" to tainted data sink "operator new[](unsigned long)". |
28 {
29 JASSERT ( size >= 0 ) ( size );
30 }
31
32 jalib::JBuffer::JBuffer ( const char* src, int size )
33 :_buffer ( new char[size] )
34 ,_size ( size )
35 {
36 JASSERT ( size >= 0 ) ( size );
37 memcpy ( _buffer, src, _size );
38 }
39
40
41 jalib::JBuffer::~JBuffer()
42 {
43 delete [] _buffer;
44 _buffer = 0;
45 _size = 0;
46 }
47
48 jalib::JBuffer::JBuffer ( const JBuffer& that )
49 : _buffer ( new char[that._size] )
50 , _size ( that._size )
51 {
52 memcpy ( _buffer, that._buffer, _size );
53 }
54
55 jalib::JBuffer& jalib::JBuffer::operator= ( const JBuffer& that )
56 {
57 delete [] _buffer;
58 _buffer = 0;
59 _size = 0;
60 new ( this ) JBuffer ( that );
61 return *this;
62 }
63
64
65 const char* jalib::JBuffer::buffer() const
66 {
67 return _buffer;
68 }
69 char* jalib::JBuffer::buffer()
70 {
71 return _buffer;
72 }
73 int jalib::JBuffer::size() const
74 {
75 return _size;
76 }
77
78
79
80