Originally Posted by
brewbuck
What you were doing is printing the address of the pointer, not the pointer itself. When you pass the pointer as a parameter, clearly the address of where this pointer exists is going to be different. The pointer itself (the address it points to) should be the same.
Do free or malloc operations on this address affect the original pointer. For instance:
Code:
$ cat -n mock_DLL.c
1 /* Mock DLL to modify a char array */
2 #include <stdio.h>
3
4 const char *text="Hi! there";
5
6 int
7 DLL_API( char *var1)
8 {
9 printf ("Inside DLL: Address of var1 %p\n",var1);
10
11 var1 = text;
12 return 0;
13 }
$ cat -n mock_test.c
1 #include <stdio.h>
2 static char *var1 = "Foobar";
3 int main()
4 {
5 int err = 0;
6
7 printf ("Address of var1 : %p\n", var1);
8 err = DLL_API (var1);
9
10 printf ("Altered value of var1 : %s\n", var1);
11
12 return err;
13 }
If not, how can I change the value referenced by the pointer in my DLL.