Hello friends,
I am using a library API , to this API iam sending a pointer variable in below two way
first way
char *ptr = NULL;
func(ptr);
second way is
funct(&ptr);
while using the first implementation i have allocated some local buffer in my lower level function in that library API and assigend as below
char *testimg = NULL;
testimg = malloc(sizeof(char) * 1024);
char data[] = "hdfdfd...."; /* This is of total size occupying 1024*/
memcpy(testimg,data,1024);
here if i do ptr = testimg
and print ptr it gives proper result in that function , but if i go to upper level funcitons / to the source program this ptr shows me as null .
In second implementation if i change the statements as below
*ptr = testimg
This gives me correct results in all uppler layer and source file .
How is this successfull when compare to the first implementation failure ?
Thanks in advance