In a previous question (changing value from function) I got help, which lead me to the next problem:
I used a string split and then a simple copy
int Crawl :: splitUrl(char ***arr, int max_length, char *url)
{
int idx=0;
char * p;
int i;
p = strtok (url,"/"); // call the strtok with str as 1st arg for the 1st time.
while (p != NULL && idx < max_length)
{
for (i=0;i<maxUrlSize-1 && p[i] != '\0';i++)
(*arr)[idx][i] = p[i];
for ( ; i< maxUrlSize-1;i++)
(*arr)[idx][i] = '\0';
printf("tmp[idx[%d]] %s %d addr: %x\n",idx,(*arr)[idx],strlen(p),(*arr)[idx]);
idx++;
p = strtok (NULL, "/");
}
The array is allocated:
split_url = new char * [ maxUrlSplit ];
printf("split_url %x\n",split_url);
for (i=0;i<maxUrlSplit;i++)
{
split_url[ i ] = new char [ maxUrlSize ];
printf("split_url[ %d ] %x\n",i,split_url[i]);
}
and after the function i used a loop to get all elements in the arry. i printet it like
printf("add: %x %s %d\n",split_url[iarr], split_url[iarr], strlen(split_url[iarr]));
The address is always the same, but after the function runs there are no entries?
I run the function like
int arr_size = crawl->splitUrl(&split_url,maxUrlSplit,url);
GDB and Valgrind don't say anything.