]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Make use of a talloc_destructor for free_printer_entry
authorVolker Lendecke <vl@samba.org>
Wed, 7 Jan 2009 17:06:21 +0000 (18:06 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 8 Jan 2009 21:29:54 +0000 (22:29 +0100)
source3/include/nt_printing.h
source3/rpc_server/srv_spoolss_nt.c

index 479404d6fd3aa40dfa21165a479be5f8f5545302..f515a408f5bee3243adad30010941f200f41cbf7 100644 (file)
@@ -452,7 +452,6 @@ typedef struct _Printer{
        bool page_started;
        uint32 jobid; /* jobid in printing backend */
        int printer_type;
-       TALLOC_CTX *ctx;
        fstring servername;
        fstring sharename;
        uint32 type;
index 744de67db428c157f3a7db477c1f7e50ba492e3b..5e2cc0505686eefc5e78a06cc9042508743e12db 100644 (file)
@@ -195,10 +195,8 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle)
  Functions to free a printer entry datastruct.
 ****************************************************************************/
 
-static void free_printer_entry(void *ptr)
+static int printer_entry_destructor(Printer_entry *Printer)
 {
-       Printer_entry *Printer = (Printer_entry *)ptr;
-
        if (Printer->notify.client_connected==True) {
                int snum = -1;
 
@@ -224,12 +222,14 @@ static void free_printer_entry(void *ptr)
        free_nt_devicemode( &Printer->nt_devmode );
        free_a_printer( &Printer->printer_info, 2 );
 
-       talloc_destroy( Printer->ctx );
-
        /* Remove from the internal list. */
        DLIST_REMOVE(printers_list, Printer);
+       return 0;
+}
 
-       SAFE_FREE(Printer);
+static void free_printer_entry(void *Printer)
+{
+       TALLOC_FREE(Printer);
 }
 
 /****************************************************************************
@@ -591,10 +591,11 @@ static bool open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3
 
        DEBUG(10,("open_printer_hnd: name [%s]\n", name));
 
-       if((new_printer=SMB_MALLOC_P(Printer_entry)) == NULL)
-               return False;
-
-       ZERO_STRUCTP(new_printer);
+       new_printer = TALLOC_ZERO_P(NULL, Printer_entry);
+       if (new_printer == NULL) {
+               return false;
+       }
+       talloc_set_destructor(new_printer, printer_entry_destructor);
 
        if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) {
                SAFE_FREE(new_printer);
@@ -606,12 +607,6 @@ static bool open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3
 
        new_printer->notify.option=NULL;
 
-       if ( !(new_printer->ctx = talloc_init("Printer Entry [%p]", hnd)) ) {
-               DEBUG(0,("open_printer_hnd: talloc_init() failed!\n"));
-               close_printer_handle(p, hnd);
-               return False;
-       }
-
        if (!set_printer_hnd_printertype(new_printer, name)) {
                close_printer_handle(p, hnd);
                return False;