summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-01 20:52:20 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-01 20:52:20 +0800
commit4c08aa1b1e04ac1b73217e13315da126b631c079 (patch)
tree2d3f295c335b2a59a900a555ab3ba1cfa6ac06fa
parent84207f6e0a54bdb8fb263ba4e0a90417e6352892 (diff)
Ticket history free functions
-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;
+}