------------------------------------------------------------------------------
| 165 | |
| 166 | //------------------------------------------------------------------------------ |
| 167 | void vtkXMLDataElement::SetCharacterData(const char* data, int length) |
| 168 | { |
| 169 | // Sanity check. |
| 170 | if (length < 0) |
| 171 | { |
| 172 | vtkWarningMacro("Negative values for length are not allowed, setting to 0!"); |
| 173 | length = 0; |
| 174 | } |
| 175 | // Mark end of buffer. |
| 176 | this->EndOfCharacterData = length + 1; |
| 177 | // Size buffer in units of blocks. |
| 178 | this->CharacterDataBufferSize = this->CharacterDataBlockSize; |
| 179 | while (this->CharacterDataBufferSize < this->EndOfCharacterData) |
| 180 | { |
| 181 | this->CharacterDataBufferSize += this->CharacterDataBlockSize; |
| 182 | } |
| 183 | // Allocate the buffer. |
| 184 | this->CharacterData = |
| 185 | static_cast<char*>(realloc(this->CharacterData, this->CharacterDataBufferSize)); |
| 186 | // Copy the data passed in. |
| 187 | if (data && length > 0) |
| 188 | { |
| 189 | memmove(this->CharacterData, data, length); |
| 190 | } |
| 191 | this->CharacterData[length] = 0; |
| 192 | // Mark us changed. |
| 193 | this->Modified(); |
| 194 | } |
| 195 | |
| 196 | //------------------------------------------------------------------------------ |
| 197 | void vtkXMLDataElement::SetAttribute(const char* name, const char* value) |
no test coverage detected