I was trying to dynamically allocate memory for a char\*\*\*.

```
char*** tas;

```

With char\*\*\* i want to describe a table of strings with 2 columns only.

Main problem i had trying to achieve that is not to compile the program but make it run without a segmentation fault.

The issue i think is the not proper use of realloc.
Checking man page of realloc/calloc/malloc

```
void *realloc(void *ptr, size_t size);
void *malloc(size_t size);
void *calloc(size_t nmemb, size_t size);

```

I found out that i have to generate the proper size\_t vars to send to allocate functions.

The crucial lines of code for this are the following:

```
tas         = (char ***)realloc(tas,sizeof(char **)*(i+1));
tas[i]      = (char **)calloc(2,sizeof(char *));
tas[i][0]   = (char *)calloc(lenKey+1,sizeof(char));
tas[i][1]   = (char *)calloc(lenValue+1,sizeof(char));
++i;

```

With `tas` beeing the char\*\*\*.

--------EDIT-------

Piece by piece I compiled an answer and i am posting the solution i found to the problem here.