Linked List simple implementation I made a simple linked list in C with the following functionalities:
Create(creates the list); Find(searches for an element in the list); Insert(inserts a value at the beginning of the list); Destroy(destroys the entire list). It only uses integers (for simplicity), and I want to know for possible errors and how to improve it in general.

The node structure:

typedef struct sllist
{
    int val;
    struct sllist* next;
}
sllnode;


The functions:

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include "node.c"

/*
 *Creates the linked list with a single value
*/
sllnode *create(int value)
{
    sllnode *node;
    node = (sllnode *) malloc(sizeof(sllnode));

    if (node == NULL)
    {
        puts("Memory error");
        return NULL;
    }

    node-&gt;val = value;
    node-&gt;next = NULL;

    return node;
}

/*
 *Searches for an element in the list.
 *Returns 1 if its found or 0 if not
*/
int find(sllnode *head, int value)
{
    sllnode *trav = head;

    do
    {
        if (trav-&gt;val == value)
        {
            return 1;
        }
        else
        {
            trav = trav-&gt;next;
        }
    } while (trav != NULL);

    return 0;
}

/*
 *Inserts a value at the beginning of the list
*/
sllnode *insert(sllnode *head, int value)
{
    sllnode *new_node = (sllnode *) malloc(sizeof(sllnode));

    if (new_node == NULL)
    {
        puts("Memory error");
        return NULL;
    }

    new_node-&gt;val = value;
    new_node-&gt;next = head;
    head = new_node;

    return head;
}

/*
 *Destroys (i.e frees) the whole list
*/
void *destroy(sllnode *head)
{
    sllnode *temp = head;

    while (temp != NULL)
    {
        free(temp);
        temp = temp-&gt;next;
    }
    free(head);
}

int main(void)
{
    return 0;
}
Including a C file

Convention is that all shared stuff is declared in .h files.

Minor 1

In destroy(), you have the return type void*. Remove the pointer star and it's fine.

Minor 2

sllnode *create(int value)
{
    sllnode *node;
    node = (sllnode *) malloc(sizeof(sllnode));

    if (node == NULL)
    {
        puts("Memory error");
        return NULL;
    }
    ...


It's a bad idea to abuse standard output from within algorithms/data structures. After all, everything that may go wrong is that there is no memory enough for the new node; returning NULL may well indicate that situation.

Minor 3

node = (sllnode *) malloc(sizeof(sllnode));


More idiomatic C is

node = malloc(sizeof *node);


Minor 4

You "append" the new nodes in reversed direction. Basically this is a (linked) stack and not a list.

Minor 5

while (temp != NULL)
{
    free(temp);
    temp = temp-&gt;next;
}


Don't do this. Instead have something like 

while (temp) 
{
    next_node = temp-&gt;next;
    free(temp);
    temp = next_node;
}


Summa summarum

For a starter, I had this in mind:

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

typedef struct linked_list_node {
    int value;
    struct linked_list_node* next;
} linked_list_node;

typedef struct {
    linked_list_node* head;
    linked_list_node* tail;
} linked_list;

void linked_list_init(linked_list* list)
{
    if (!list)
    {
        return;
    }

    list-&gt;head = NULL;
    list-&gt;tail = NULL;
}

void linked_list_free(linked_list* list)
{
    linked_list_node* current_node;
    linked_list_node* next_node;

    if (!list)
    {
        return;
    }

    current_node = list-&gt;head;

    while (current_node)
    {
        next_node = current_node-&gt;next;
        free(current_node);
        current_node = next_node;
    }
}

int linked_list_append(linked_list* list, int value)
{
    linked_list_node* new_node;

    if (!list)
    {
        return 1;
    }

    new_node = malloc(sizeof *new_node);

    if (!new_node)
    {
        return 1;
    }

    new_node-&gt;value = value;

    if (list-&gt;head)
    {
        list-&gt;tail-&gt;next = new_node;
    }
    else
    {
        list-&gt;head = new_node;
    }

    list-&gt;tail = new_node;
    return 0;
}

int linked_list_index_of(linked_list* list, int value)
{
    int index;
    linked_list_node* node;

    if (!list)
    {
        return -2;
    }

    for (node = list-&gt;head, index = 0; node; node = node-&gt;next, index++)
    {
        if (node-&gt;value == value)
        {
            return index;
        }
    }

    return -1;
}

int main() {
    int i;

    linked_list my_list;
    linked_list_init(&amp;my_list);

    for (i = 0; i &lt; 10; ++i)
    {
        linked_list_append(&amp;my_list, i);
    }

    printf("%d %d\n",
           linked_list_index_of(&amp;my_list, 4),
           linked_list_index_of(&amp;my_list, 100));

    linked_list_free(&amp;my_list);
    return 0;
}


Hope that helps.