2018-01-01 18:56:07 +00:00
|
|
|
/*
|
|
|
|
* Stairs
|
|
|
|
* Copyright 2017 (c) Mark van Renswoude
|
|
|
|
*
|
|
|
|
* https://git.x2software.net/pub/Stairs
|
|
|
|
*/
|
|
|
|
#include "charproperties.h"
|
|
|
|
#include <cstddef>
|
|
|
|
#include <string.h>
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
void CharProperties::assignChar(char** field, const char* newValue)
|
|
|
|
{
|
2018-01-07 22:12:42 +00:00
|
|
|
if (*field != nullptr)
|
2018-01-01 18:56:07 +00:00
|
|
|
delete *field;
|
|
|
|
|
2018-01-07 22:12:42 +00:00
|
|
|
if (newValue != nullptr)
|
2018-01-01 18:56:07 +00:00
|
|
|
{
|
|
|
|
// Include the terminating null character
|
|
|
|
size_t length = strlen(newValue) + 1;
|
|
|
|
*field = new char[length];
|
|
|
|
strncpy(*field, newValue, length);
|
|
|
|
}
|
|
|
|
else
|
2018-01-07 22:12:42 +00:00
|
|
|
*field = nullptr;
|
2018-01-01 18:56:07 +00:00
|
|
|
}
|