Need help to understand small part of sourcecode

andreas moroder claudiamoroder at st-ulrich.suedtirol.net
Fri Dec 28 14:00:09 GMT 2001


Hello,

it would be nice if anyone could explain me the following sections of source 
code

In smbd/reply.c  in the function    reply_printqueue ( line 2550 .. )

 print_queue_status(SNUM(conn), &queue,NULL) is called with the 3th parameter 
NULL.

in printing/printing.c there is the function print_queue_status

.....
        ZERO_STRUCTP(status);
        slprintf(keystr, sizeof(keystr)-1, "STATUS/%s", lp_servicename(snum));
        key.dptr = keystr;
        key.dsize = strlen(keystr);
        data = tdb_fetch(tdb, key);
        if (data.dptr) {
                if (data.dsize == sizeof(*status)) {
                        memcpy(status, data.dptr, sizeof(*status));    <- ??  
      
                }
                SAFE_FREE(data.dptr);
        }                                                                     
  
the line <-?? is not clear to me

if status is passed as NULL, the first parameter of memcopy is NULL. How can 
data.ptr be copied to nowhere ?

Do I miss anything ? 

(  I begin to have doubts, that memcpy(status, data.dptr, sizeof(*status)) 
copies the pointer data.dptr to the pointer status ( not the data ), but in 
this case the SAFE_FREE would free the data status points )

Thank you for your help

Andreas




More information about the samba-technical mailing list