summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/messages.c25
-rw-r--r--utils/messages.h8
2 files changed, 33 insertions, 0 deletions
diff --git a/utils/messages.c b/utils/messages.c
index e69a85524..0c558cdfc 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -177,6 +177,22 @@ messages_get_ctx(const char *key, struct hash_table *ctx)
return r;
}
+
+/**
+ * Free memory used by a messages hash.
+ * The context will not be valid after this function returns.
+ *
+ * \param ctx context of messages file to free
+ */
+static void messages_destroy_ctx(struct hash_table *ctx)
+{
+ if (ctx == NULL)
+ return;
+
+ hash_destroy(ctx);
+}
+
+
/* exported interface documented in messages.h */
nserror messages_add_from_file(const char *path)
{
@@ -390,3 +406,12 @@ const char *messages_get_errorcode(nserror code)
/* Unknown error */
return messages_get_ctx("Unknown", messages_hash);
}
+
+
+/* exported function documented in utils/messages.h */
+void messages_destroy(void)
+{
+ messages_destroy_ctx(messages_hash);
+ messages_hash = NULL;
+}
+
diff --git a/utils/messages.h b/utils/messages.h
index 784e5fe6a..d4be893af 100644
--- a/utils/messages.h
+++ b/utils/messages.h
@@ -90,4 +90,12 @@ const char *messages_get_errorcode(nserror code);
char *messages_get_buff(const char *key, ...);
+/**
+ * Free memory used by the standard Messages hash
+ *
+ * \param code errorcode of message
+ * \return message text
+ */
+void messages_destroy(void);
+
#endif