Sorry, memcpy was a bad example. The parms to that are pointers, not dereferenced pointers.
memcpy(foo, ld, 10); didn't work? I guess that's something to do with "incomplete type". I'm not familiar with that. My suggestion still sort of stands though. Try: memcpy(foo, (char *) ld, 10); and for the 2nd example: memcpy(foo, bar, 10); In article <[email protected]> you wrote: > Dave, > You need to cast to a pointer type that memcpy (or whatever) can > handle. e.g. > memcpy(foo, *((char *) ld), 10); > If you want to use this a lot, it might be better to just copy > to a pointer of another type: > char *bar; > bar = (char *) ld; > memcpy(foo, *bar, 10); > Also, I find it beneficial to display addresses in hex. e.g. > printf("ld before bind :%08X\n",ld); > In article <[email protected]> you > wrote: > > This is my first experience with C, but a language is a language after > > the 3rd or 4th :) > > I'm calling C for LDAP queries from Natural (Software AG "4"GL) in batch. > > And it works, sort of. > > One FM is IBM Tivoli Directory Server Client Programming for z/OS > > If I use the sequence ldap_init, ldap_simple_bind_s, ldap_search, > > ldap_unbind, it gets overloaded after 5 calls at the speed of batch. If I > > leave out the unbind, it works for thousands of calls, but there is an > > obvious memory leak. > > So, I want to anchor the ldap handle in the main driving program. I made > > a simple C stub: > > > > extern int ret2nat (int *back_value, LDAP *ld, char *msg) > > #include <ldap.h> > > In ldap.h there is: > > typedef struct ldap LDAP; > > The examples use: > > LDAP * ld; > > To declare an ldap_handle which according to the listing is an: > > ld 6270-1:1931 Class = parameter, Length = 4 > > Type = pointer to incomplete struct ldap > > > > I have a function: > > LDAP * bind_adlds(char *hostname, char *container, char *msg) > > And I call it: > > printf("ld before bind :%d\n",ld); /* ld before bind > > :286352012 > > ld = bind_adlds(hostname, container, msg) ; > > printf("ld after bind :%d\n",ld); /* ld after bind > > :283317144 > > but the value is not returned to the caller of ret2nat. > > > > Any attempts to use *ld in an assignment or even memcpy() get a complier > > message: > > ERROR CCN3285 /u/ldap/test.c:46 The indirection operator cannot be > > applied to a pointer to an incomplete struct or union. > > > > > > Or > > WARNING CCN3068 /u/ldap/test.c:46 Operation between types "int*" and > > "pointer to an incomplete type" is not allowed. > > As I said, I am just learning how to spell C. I know I am fighting some > > kind of battle of types. I welcome even derisive comments, if in the end > > thay help. > > Dave Gibney > > Information Technology Services > > Washington State University -- Don Poitras - SAS Development - SAS Institute Inc. - SAS Campus Drive [email protected] (919) 531-5637 Cary, NC 27513 ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html

