X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fmessage.c;h=6bc8344a4d06bfb40b3b21a8d46fe8057366a9b3;hb=2153ca9b3cb9616c616a4b58abb300de1f317541;hp=34ca65ce5598018dc1e10641c0e45eebb6091a9e;hpb=4d86bb87eedc899cdfe0df8f9f2367080db8c7cc;p=pspp diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 34ca65ce55..6bc8344a4d 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -68,6 +69,27 @@ msg_done (void) { } + +/* Duplicate a message */ +struct msg * +msg_dup(const struct msg *m) +{ + struct msg *new_msg = xmalloc (sizeof *m); + + *new_msg = *m; + new_msg->text = strdup(m->text); + + return new_msg; +} + +void +msg_destroy(struct msg *m) +{ + free(m->text); + free(m); +} + + /* Emits M as an error message. Frees allocated data in M. */ void