From 35c0333a09cee6c6f7d72e6c2459110a65d51a3d Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 29 Apr 2023 16:08:37 +0200 Subject: make struct ci_queue_entry opaque --- src/ci_queue.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'src/ci_queue.c') diff --git a/src/ci_queue.c b/src/ci_queue.c index 97fc257..6429580 100644 --- a/src/ci_queue.c +++ b/src/ci_queue.c @@ -12,14 +12,28 @@ #include #include -int ci_queue_entry_create(struct ci_queue_entry **entry, const char *_url, const char *_rev) +struct ci_queue_entry { + char *url; + char *rev; + STAILQ_ENTRY(ci_queue_entry) entries; +}; + +int ci_queue_entry_create(struct ci_queue_entry **_entry, const char *_url, const char *_rev) { + struct ci_queue_entry *entry; char *url, *rev; + *_entry = malloc(sizeof(struct ci_queue_entry)); + if (!*_entry) { + log_errno("malloc"); + goto fail; + } + entry = *_entry; + url = strdup(_url); if (!url) { log_errno("strdup"); - goto fail; + goto free_entry; } rev = strdup(_rev); @@ -28,22 +42,17 @@ int ci_queue_entry_create(struct ci_queue_entry **entry, const char *_url, const goto free_url; } - *entry = malloc(sizeof(struct ci_queue_entry)); - if (!*entry) { - log_errno("malloc"); - goto free_rev; - } - (*entry)->url = url; - (*entry)->rev = rev; + entry->url = url; + entry->rev = rev; return 0; -free_rev: - free(rev); - free_url: free(url); +free_entry: + free(entry); + fail: return -1; } @@ -55,6 +64,16 @@ void ci_queue_entry_destroy(struct ci_queue_entry *entry) free(entry); } +const char *ci_queue_entry_get_url(const struct ci_queue_entry *entry) +{ + return entry->rev; +} + +const char *ci_queue_entry_get_rev(const struct ci_queue_entry *entry) +{ + return entry->rev; +} + void ci_queue_create(struct ci_queue *queue) { STAILQ_INIT(queue); -- cgit v1.2.3