add timespec_empty()

This commit is contained in:
Pim van Pelt
2018-11-04 19:55:54 +01:00
parent 9af4c4b3a6
commit 8c6b2f399b
2 changed files with 9 additions and 0 deletions

View File

@ -43,6 +43,7 @@ struct mgos_timespec;
struct mgos_timespec *timespec_create(); struct mgos_timespec *timespec_create();
bool timespec_destroy(struct mgos_timespec **ts); 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_add_spec(struct mgos_timespec *ts, const char *spec);
bool timespec_clear_spec(struct mgos_timespec *ts); bool timespec_clear_spec(struct mgos_timespec *ts);
bool timespec_get_spec(struct mgos_timespec *ts, char *ret, int retlen); bool timespec_get_spec(struct mgos_timespec *ts, char *ret, int retlen);

View File

@ -216,6 +216,14 @@ bool timespec_clear_spec(struct mgos_timespec *ts) {
return true; 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 // Return a null terminated string in 'ret' of max retlen-1 which is a
// comma separated set of timespec elements from the linked list. // comma separated set of timespec elements from the linked list.
// Returns true on success, false otherwise. // Returns true on success, false otherwise.