I am trying to understand how to free up memory fully after calls to `strtok()`. I read most of the answered questions here and none seemed to address the point of my confusion. If this is a duplicate feel free to point me to the direction of something that answers my question

```
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char * aliteral = "Hello/world/fine/you";

    char * allocatedstring;

    char * token;
    int i=0;

    allocatedstring=(char *) malloc(sizeof(allocatedstring)*21);
    allocatedstring=strcpy(allocatedstring,aliteral);

    token = strtok(allocatedstring, "/");
    token = strtok(NULL, "/");
    token = strtok(NULL, "/");
    token = strtok(NULL, "/");

    printf("%s\n",allocatedstring);
    printf("%s\n",token);

    free(allocatedstring);

    return 0;
}

```

Freeing `allocatedstring` here only frees up the string up to the first `\0` character that replaced strtok's delimiter. So it only clears up until "Hello". I checked that using eclipse debugger and monitoring the memory addresses. 

How do I clear the rest of it? I tried 2 things, having 1 extra pointer point to the start of allocatedstring and freeing that (didnt work) and freeing token after call to `strtok()` (didnt work either)

So how do I clean up the parts of `allocatedstring` that are now between `\0` 's ? 

**EDIT :** To clarify, seeing the memory address blocks in eclipse debugger, I was seeing the string "HELLO WORLD FINE YOU" in the memory blocks that were initially allocated by the call to `malloc`. After the call to `free()`, the blocks containing "HELLO" and the first `\0` turned to gibberish, but the rest of the blocks kept the characters "FINE YOU". I assumed that meant that they were not freed.