Without seeing more of your code, you look like you may have undefined behavior in your code.
With the declaration of Destination
you have an array of pointers to a pointer, and I don't know if that's what you want. You also need to allocate all the pointers.
You also have to be careful as strtok
modifies the string it tokenizes, so you can't pass a literal or constant string.
If it was me, I would do something like this instead:
char **Destination = NULL;
StoreArr(Original, &Destination);
And have the function like this
size_t StoreArr(char *original, char ***destination)
{
if (original == NULL || destination == NULL)
return 0;
size_t size = 0;
char *token = strtok(original, " ");
while (token != NULL)
{
/* (re)allocate array */
char **temp = realloc(*destination, sizeof(char *) * (size + 1));
if (temp == NULL)
{
/* Allocation failed, free what we have so far */
if (*destination != NULL)
{
for (size_t i = 0; i < size; ++i)
free((*destination)[i]);
free(*destination);
}
return 0;
}
/* Set the destination pointer */
*destination = temp;
/* Duplicate the token */
(*destination)[size++] = strdup(token);
/* Get next token */
token = strtok(NULL, " ");
}
return size;
}
The function now dynamically allocates new entries as needed, and returns the number of entries in the array or 0
on error.