View difference between Paste ID: HNgHmM9c and 2GZu4VqY
SHOW: | | - or go back to the newest paste.
1
	// returns the address of the pointer to field's data
2
	void* CField::data() const{
3
		return _fData;
4
	}
5
6
	// sets the address of the field's data
7
	void CField::data(void* tmp) {
8
		_fData = tmp;
9
	}
10
11
12
// allocates dynamic memory for the C-style null-terminated string at the received address and 
13
	// copies that data into the newly allocated memory
14
        void CLine::allocateAndCopy(const char* Str){
15
                alloc = true;
16
                void* tmp = new char[_maxDatalen + 1];
17
                data(tmp);
18-
                std::strcpy(*(char**)data(), Str);
18+
                std::strcpy(*(char**)tmp, Str);
19-
                (*(char**)data())[_maxDatalen] = '\0';
19+
                (*(char**)tmp)[_maxDatalen] = '\0';
20
        }