summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rtclient/ticket.h4
-rw-r--r--ticket.c35
2 files changed, 39 insertions, 0 deletions
diff --git a/rtclient/ticket.h b/rtclient/ticket.h
index c48a121..d8b7b8d 100644
--- a/rtclient/ticket.h
+++ b/rtclient/ticket.h
@@ -72,6 +72,10 @@ extern "C" {
, const char *text);
void rtclient_ticket_history(struct rtclient_ticket_history_list **listptr
, unsigned int id);
+ void rtclient_ticket_history_free
+ (struct rtclient_ticket_history *history);
+ void rtclient_ticket_history_list_free
+ (struct rtclient_ticket_history_list *list);
#ifdef __cplusplus
}
diff --git a/ticket.c b/ticket.c
index 821f982..161f079 100644
--- a/ticket.c
+++ b/ticket.c
@@ -3,6 +3,7 @@
#include "rtclient/ticket.h"
typedef struct rtclient_ticket rtclient_ticket;
+typedef struct rtclient_ticket_history_attachment rtclient_ticket_history_attachment;
typedef struct rtclient_ticket_history_list rtclient_ticket_history_list;
void rtclient_ticket_new(const char *queue
@@ -247,3 +248,37 @@ void rtclient_ticket_history(rtclient_ticket_history_list **listptr
request(history_handler, (void *)listptr, NULL, "%s%u%s"
, "REST/1.0/ticket/", id, "/history?format=l");
}
+
+void rtclient_ticket_history_free(struct rtclient_ticket_history *history)
+{
+ if (history->attachments) {
+ for(size_t i = 0; i < history->attachments->length; i++) {
+ rtclient_ticket_history_attachment *attachment
+ = history->attachments->attachments[i];
+ if (attachment->file_name)
+ free(attachment->file_name);
+ free(attachment);
+ }
+ free(history->attachments);
+ }
+ free(history->created);
+ free(history->creator);
+ free(history->content);
+ free(history->description);
+ if (history->data)
+ free(history->data);
+ if (history->new_value)
+ free(history->new_value);
+ if (history->old_value)
+ free(history->old_value);
+ free(history);
+ history = NULL;
+}
+
+void rtclient_ticket_history_list_free(struct rtclient_ticket_history_list *list)
+{
+ for (size_t i = 0; i < list->length; i++)
+ rtclient_ticket_history_free(list->histories[i]);
+ free(list);
+ list = NULL;
+}