diff options
author | Volker Lendecke <vl@samba.org> | 2009-01-07 18:06:21 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-01-08 22:29:54 +0100 |
commit | e94d7f53f9339b73ee5b20f5061b9b74f9866cee (patch) | |
tree | 58b40240b574d356f1533235bb814d5750d9c222 /source3/rpc_server | |
parent | baa5c5eeb0c86ac9ae9edfd15da2621d2959938a (diff) | |
download | samba-e94d7f53f9339b73ee5b20f5061b9b74f9866cee.tar.gz samba-e94d7f53f9339b73ee5b20f5061b9b74f9866cee.tar.bz2 samba-e94d7f53f9339b73ee5b20f5061b9b74f9866cee.zip |
Make use of a talloc_destructor for free_printer_entry
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 744de67db4..5e2cc05056 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -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; |