From 8c6b2f399b79315317013e8d0b2ba2efac435fd3 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Sun, 4 Nov 2018 19:55:54 +0100 Subject: [PATCH] add timespec_empty() --- include/timespec.h | 1 + src/timespec.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/timespec.h b/include/timespec.h index 97330cf..e58fe6a 100644 --- a/include/timespec.h +++ b/include/timespec.h @@ -43,6 +43,7 @@ struct mgos_timespec; struct mgos_timespec *timespec_create(); bool timespec_destroy(struct mgos_timespec **ts); +bool timespec_empty(struct mgos_timespec *ts); bool timespec_add_spec(struct mgos_timespec *ts, const char *spec); bool timespec_clear_spec(struct mgos_timespec *ts); bool timespec_get_spec(struct mgos_timespec *ts, char *ret, int retlen); diff --git a/src/timespec.c b/src/timespec.c index 9cbb7b2..481f037 100644 --- a/src/timespec.c +++ b/src/timespec.c @@ -216,6 +216,14 @@ bool timespec_clear_spec(struct mgos_timespec *ts) { return true; } +// Return true if the timespec is empty +bool timespec_empty(struct mgos_timespec *ts) { + if (!ts) { + return true; + } + return SLIST_EMPTY(&ts->specs); +} + // Return a null terminated string in 'ret' of max retlen-1 which is a // comma separated set of timespec elements from the linked list. // Returns true on success, false otherwise.