23 if (text != NULL && name != NULL)
25 memento = calloc(1,
sizeof(
Memento));
30 if (memento->
name != NULL)
34 if (memento->
text == NULL)
36 printf(
" Error! Out of memory preserving text in the Memento!\n");
37 free((
char*)memento->
name);
44 printf(
" Error! Out of memory duplicating the Memento's name.\n");
51 printf(
" Error! Out of memory creating a Memento.\n");
67 free((
char*)memento->
name);
void Memento_Destroy(Memento *memento)
Destroy an existing instance of the Memento structure. After this function returns,...
Memento * Memento_Create(const char *text, const char *name)
Create a new instance of the Memento structure, initialized to the given text and name.
Declaration of the Memento structure and support functions, Memento_Create() and Memento_Destroy(),...
Declaration of the STRDUP macro that hides the differences between how strdup() is declared in differ...
#define STRDUP
Define STRDUP to be the operating system-specific version of strdup().
Represents a single memento (snapshot) of the text state before an operation is applied....
char * text
The snapshot to be remembered by the Memento.
const char * name
The operation name that triggered the need for this Memento.