diff --git a/Makefile b/Makefile index 41da593..4957dc5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: all clean all: - $(CC) main.c -o main + $(CC) main.c syllable.c -o main ./main clean: diff --git a/syllable.c b/syllable.c new file mode 100644 index 0000000..bdd619c --- /dev/null +++ b/syllable.c @@ -0,0 +1,32 @@ +#include +#include +#include "syllable.h" + + +struct syllable *syllable_alloc(const char *data) +{ + struct syllable *ptr = malloc(sizeof(*ptr)); + + if (ptr == NULL) + return NULL; + + ptr->data = strdup(data); + ptr->next = NULL; + + return ptr; +} + +void syllable_drop(struct syllable *ptr) +{ + free(ptr); +} + +struct syllable *syllable_append(struct syllable *tail, const char *data) +{ + struct syllable *ptr; + + ptr = syllable_alloc(data); + tail->next = ptr; + + return ptr; +} diff --git a/syllable.h b/syllable.h new file mode 100644 index 0000000..7c2b426 --- /dev/null +++ b/syllable.h @@ -0,0 +1,14 @@ +#ifndef __SYLLABE_H +#define __SYLLABE_H + +struct syllable { + char *data; + struct syllable *next; +}; + +struct syllable *syllable_alloc(); +void syllable_drop(struct syllable *syllable); + +struct syllable *syllable_append(struct syllable *tail, const char *data); + +#endif /* __SYLLABE_H */