linked list in c code I have implemented linked list data structure in c.

linkedlist.h

#ifndef LINKED_LIST
#define LINKED_LIST

#include &lt;stdbool.h&gt;

struct linkedlist {
    int key;
    struct linkedlist* next;
    struct linkedlist* prev;
};

bool list_insert(struct linkedlist** p,int k);
struct linkedlist* list_search(struct linkedlist* p,int k);
bool list_delete(struct linkedlist** p,int k);
void list_show(struct linkedlist* p);
void memory_map(struct linkedlist* p);

#endif


list.c

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

bool list_insert(struct linkedlist** p,int k) {
    struct linkedlist* x = malloc(sizeof (struct linkedlist));
    if(!x) 
    {
        return false;       
    }
    x-&gt;key = k;
    x-&gt;prev = NULL;
    x-&gt;next = *p;   

    if(*p)
    {
        (*p)-&gt;prev = x;
    }   
    *p = x;
    return true;
}

struct linkedlist* list_search(struct linkedlist* p,int k) {
    if(!p) 
    {
        return NULL;
    }

    while(p != NULL)
    {
        if(p-&gt;key == k)
        {
            return p;       
        }
        p = p-&gt;next;        
    }
    return NULL;
}

bool list_delete(struct linkedlist** p,int k) {
    struct linkedlist* x = list_search(*p,k);
    if(!x) 
    {   
        return false;
    }   
    if(x-&gt;prev)
    {
        x-&gt;prev-&gt;next = x-&gt;next;
    }
    if(x-&gt;next)
    {
        x-&gt;next-&gt;prev = x-&gt;prev;
    }

    free(x);
    return true;
}

void list_show(struct linkedlist* p) {
    printf("\n[linkedlist][");
    while(p) 
    {
        printf("%d ",p-&gt;key);
        p = p-&gt;next;
    }
    printf("]");
}
void memory_map(struct linkedlist* p) {
        printf("\n[memory map for linkedlist]");
        while(p)
        {
                printf("\n%d : [%p]", p-&gt;key,p);
                p = p-&gt;next;
        }
}


main.c

#include &lt;stdio.h&gt;
#include "linkedlist.h"

int main() 
{
    struct  linkedlist* head = NULL;
    int i;
    for(i = 0; i &lt; 5; i++) 
    {
        if(!list_insert(&amp;head,i+1))
            printf("list_insert operation fails");
    }
    list_show(head);
    memory_map(head);   
    list_delete(&amp;head,2);
    list_delete(&amp;head,1);
    list_delete(&amp;head,3);
    list_insert(&amp;head,18);
    list_show(head);
    memory_map(head);
    return 0;
}
Naming

You should consider renaming or removing Your memory_map() function, all functions from Your linkedlist library does have a prefix list_, and this one does not. Also, it's kind a misleading. For user of Your library it might look like something related to mmap().

What does p, k, x mean? Please, consider using proper names for Your variables.

Verbosity

Just returning false in case of error usually is not verbose enough. I'd suggest considering proper error codes and/or proper error logger, for example something like this:

#ifndef LLIST_LOG
#define LLIST_LOG(format, ...) \
    fprintf(stderr, "LLIST_LOG: %s(): " format "\n", \
          __FUNCTION__, ##__VA_ARGS__)
#endif /* LLIST_LOG */


Consistency

Spacing and indentation is inconsistent. You should decide, how many spaces do You put between functions, how and when You separate if() {}, while() {}, arithmetical operations, etc blocks from each other or other logical parts of Your code. Or even better, use already defined C coding style, for example Linux kernel one.

Input verification

Rule of thumb, user of Your library is going to be dumb. And/or it will get messy debugging bigger project with Your library included. So, really, verify ALL the inputs. For example, Your list_delete(NULL, 1) segfaults.

Generic practices

Back to memory_map(), in general it's quite common to provide iterator function which calls some callback with every single element of the structure as a parameter instead. It's way more versatile.

It's common to suffix include guards by some randomly generated gibberish or hash, especially for such a common names as LINKED_LIST. Also, for compatibility with some compilers it usually defines it to some specific value. For example:

#ifndef LINKED_LIST_H_093e74eeda79fcc4c29e9d2986f5b701
#define LINKED_LIST_H_093e74eeda79fcc4c29e9d2986f5b701 1


Also, You should consider adding function list_create() and list_destroy() for Your library user not to mess with malloc() and free() directly and handle errors properly there.

Generic rant

There is a memory leak in Your example ;)