sanskrit-iast/syllable.c

33 lines
482 B
C
Raw Normal View History

2018-04-25 15:16:12 +02:00
#include <stdlib.h>
#include <string.h>
#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;
}