Advertisement
Iv4n

Untitled

Mar 11th, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  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);
  19.                 (*(char**)data())[_maxDatalen] = '\0';
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement