I am calling a function recursively and which is allocating 2048 byte is being allocated in each call.At start the application is running as per requirement but later it is getting crashed by giving the error that "Not enough storage is available to process this command". And the memory allocator returns bad pointer of memory,for which the application is being crashed.can any one please help me on this issue.
char* parser(char *data){
char *string,*ptr,*result;
int len;
len=strlen(data);
ptr=strstr(data,"search");
if(ptr){
buf = (char *)GlobalAlloc(GPTR,sizeof(char)*len+1);
strncpy(buf,data,ptr-data);
buf[ptr-data]='\0';
result=parser(buf);
GlobalFree(buf);
return result;
}
}