diff options
author | Sascha Silbe <sascha-pgp@silbe.org> | 2010-07-21 17:30:43 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha-pgp@silbe.org> | 2010-07-21 17:30:43 (GMT) |
commit | 5ab8ddb8ddb8dc6925cb3bb5f52e0a06b7a1c439 (patch) | |
tree | 01e6ca6d9d6eaa54052480200f039c8e50f0166f /nss/slist.c | |
parent | d4fe57f377d8f78f02a9e5f6d9c201b4e9eb86f4 (diff) |
rearrange source tree to match that of the tarball
Diffstat (limited to 'nss/slist.c')
-rw-r--r-- | nss/slist.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nss/slist.c b/nss/slist.c new file mode 100644 index 0000000..160c17e --- /dev/null +++ b/nss/slist.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <stdint.h> +#include <stdbool.h> + +#include "slist.h" + +void slist_init(struct slist* self) { + self->next = self; +} + +bool slist_null(struct slist* self) { + return self == self->next; +} + +bool slist_non_null(struct slist* self) { + return self != self->next; +} + +void slist_extend(struct slist* self, struct slist* rhs) { + rhs->next = self->next; + self->next = rhs; +} + +size_t slist_length(struct slist* self) { + /* XXX: Arithmetic overflow! */ + size_t result = 0; + while (slist_non_null(self)) { + result++; + self = self->next; + } + return result; +} |