Stairs/src/charproperties.cpp

26 lines
526 B
C++

/*
* 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)
{
if (*field != nullptr)
delete *field;
if (newValue != nullptr)
{
// Include the terminating null character
size_t length = strlen(newValue) + 1;
*field = new char[length];
strncpy(*field, newValue, length);
}
else
*field = nullptr;
}