From 091dbaa00bfb970137290a306ee77b4c5255b6c2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 09:25:57 +0000 Subject: move to SAFE_FREE() (This used to be commit 09bf4425492fd96672ddd7a31d88854adcf7f0fe) --- source3/printing/load.c | 4 +- source3/printing/nt_printing.c | 91 +++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 52 deletions(-) diff --git a/source3/printing/load.c b/source3/printing/load.c index c4fc3377c3..ae76229d77 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -48,7 +48,7 @@ static void add_auto_printers(void) printers = lp_servicenumber(PRINTERS_NAME); if (printers < 0) { - free(str); + SAFE_FREE(str); return; } @@ -60,7 +60,7 @@ static void add_auto_printers(void) } } - free(str); + SAFE_FREE(str); } /*************************************************************************** diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 3c029775d0..1a1c71fe39 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -222,7 +222,7 @@ static BOOL upgrade_to_version_2(void) } } - safe_free(dbuf.dptr); + SAFE_FREE(dbuf.dptr); } return True; @@ -334,7 +334,7 @@ int get_ntforms(nt_forms_struct **list) ret = tdb_unpack(dbuf.dptr, dbuf.dsize, "dddddddd", &i, &form.flag, &form.width, &form.length, &form.left, &form.top, &form.right, &form.bottom); - safe_free(dbuf.dptr); + SAFE_FREE(dbuf.dptr); if (ret != dbuf.dsize) continue; tl = Realloc(*list, sizeof(nt_forms_struct)*(n+1)); @@ -635,7 +635,7 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, /* get the section table */ num_sections = SVAL(buf,PE_HEADER_NUMBER_OF_SECTIONS); section_table_bytes = num_sections * PE_HEADER_SECT_HEADER_SIZE; - free(buf); + SAFE_FREE(buf); if ((buf=malloc(section_table_bytes)) == NULL) { DEBUG(0,("get_file_version: PE file [%s] section table malloc failed bytes = %d\n", fname, section_table_bytes)); @@ -656,7 +656,7 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, int section_pos = IVAL(buf,sec_offset+PE_HEADER_SECT_PTR_DATA_OFFSET); int section_bytes = IVAL(buf,sec_offset+PE_HEADER_SECT_SIZE_DATA_OFFSET); - free(buf); + SAFE_FREE(buf); if ((buf=malloc(section_bytes)) == NULL) { DEBUG(0,("get_file_version: PE file [%s] version malloc failed bytes = %d\n", fname, section_bytes)); @@ -690,7 +690,7 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, fname, *major, *minor, (*major>>16)&0xffff, *major&0xffff, (*minor>>16)&0xffff, *minor&0xffff)); - free(buf); + SAFE_FREE(buf); return True; } } @@ -700,7 +700,7 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, /* Version info not found, fall back to origin date/time */ DEBUG(10,("get_file_version: PE file [%s] has no version info\n", fname)); - free(buf); + SAFE_FREE(buf); return False; } else if (SVAL(buf,NE_HEADER_SIGNATURE_OFFSET) == NE_HEADER_SIGNATURE) { @@ -713,7 +713,7 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, } /* Allocate a bit more space to speed up things */ - free(buf); + SAFE_FREE(buf); if ((buf=malloc(VS_NE_BUF_SIZE)) == NULL) { DEBUG(0,("get_file_version: NE file [%s] malloc failed bytes = %d\n", fname, PE_HEADER_SIZE)); @@ -767,7 +767,7 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, fname, *major, *minor, (*major>>16)&0xffff, *major&0xffff, (*minor>>16)&0xffff, *minor&0xffff)); - free(buf); + SAFE_FREE(buf); return True; } } @@ -775,7 +775,7 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, /* Version info not found, fall back to origin date/time */ DEBUG(0,("get_file_version: NE file [%s] Version info not found\n", fname)); - free(buf); + SAFE_FREE(buf); return False; } else @@ -784,11 +784,11 @@ static BOOL get_file_version(files_struct *fsp, char *fname,uint32 *major, fname, IVAL(buf,PE_HEADER_SIGNATURE_OFFSET))); no_version_info: - free(buf); + SAFE_FREE(buf); return False; error_exit: - free(buf); + SAFE_FREE(buf); return -1; } @@ -1530,7 +1530,7 @@ done: if (ret) DEBUG(0,("add_a_printer_driver_3: Adding driver with key %s failed.\n", key )); - safe_free(buf); + SAFE_FREE(buf); return ret; } @@ -1641,11 +1641,10 @@ static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, if (driver.dependentfiles != NULL) fstrcpy(driver.dependentfiles[i], ""); - safe_free(dbuf.dptr); + SAFE_FREE(dbuf.dptr); if (len != dbuf.dsize) { - if (driver.dependentfiles != NULL) - safe_free(driver.dependentfiles); + SAFE_FREE(driver.dependentfiles); return get_a_printer_driver_3_default(info_ptr, in_prt, in_arch); } @@ -1710,7 +1709,7 @@ uint32 get_a_printer_driver_9x_compatible(pstring line, fstring model) pstrcat(line, info3->dependentfiles[i]); } - free(info3); + SAFE_FREE(info3); return True; } @@ -1963,7 +1962,7 @@ done: if (!W_ERROR_IS_OK(ret)) DEBUG(8, ("error updating printer to tdb on disk\n")); - safe_free(buf); + SAFE_FREE(buf); DEBUG(8,("packed printer [%s] with driver [%s] portname=[%s] len=%d\n", info->sharename, info->drivername, info->portname, len)); @@ -2014,8 +2013,8 @@ BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_ (strlen(current->value)==strlen(param->value)) ) { DEBUG(109,("deleting first value\n")); info_2->specific=current->next; - safe_free(current->data); - safe_free(current); + SAFE_FREE(current->data); + SAFE_FREE(current); DEBUG(109,("deleted first value\n")); return (True); } @@ -2027,8 +2026,8 @@ BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_ strlen(current->value)==strlen(param->value) ) { DEBUG(109,("deleting current value\n")); previous->next=current->next; - safe_free(current->data); - safe_free(current); + SAFE_FREE(current->data); + SAFE_FREE(current); DEBUG(109,("deleted current value\n")); return(True); } @@ -2051,11 +2050,8 @@ void free_nt_printer_param(NT_PRINTER_PARAM **param_ptr) DEBUG(106,("free_nt_printer_param: deleting param [%s]\n", param->value)); - if(param->data) - safe_free(param->data); - - safe_free(param); - *param_ptr = NULL; + SAFE_FREE(param->data); + SAFE_FREE(*param_ptr); } /**************************************************************************** @@ -2141,7 +2137,7 @@ NT_DEVICEMODE *dup_nt_devicemode(NT_DEVICEMODE *nt_devicemode) new_nt_devicemode->private = NULL; if (nt_devicemode->private != NULL) { if ((new_nt_devicemode->private = memdup(nt_devicemode->private, nt_devicemode->driverextra)) == NULL) { - safe_free(new_nt_devicemode); + SAFE_FREE(new_nt_devicemode); DEBUG(0,("dup_nt_devicemode: malloc fail.\n")); return NULL; } @@ -2163,11 +2159,8 @@ void free_nt_devicemode(NT_DEVICEMODE **devmode_ptr) DEBUG(106,("free_nt_devicemode: deleting DEVMODE\n")); - if(nt_devmode->private) - safe_free(nt_devmode->private); - - safe_free(nt_devmode); - *devmode_ptr = NULL; + SAFE_FREE(nt_devmode->private); + SAFE_FREE(*devmode_ptr); } /**************************************************************************** @@ -2192,8 +2185,7 @@ static void free_nt_printer_info_level_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr) free_nt_printer_param(&tofree); } - safe_free(*info_ptr); - *info_ptr = NULL; + SAFE_FREE(*info_ptr); } @@ -2531,7 +2523,7 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen if (get_remote_arch() == RA_OS2) map_to_os2_driver(info.drivername); - safe_free(dbuf.dptr); + SAFE_FREE(dbuf.dptr); *info_ptr=memdup(&info, sizeof(info)); DEBUG(9,("Unpacked printer [%s] name [%s] running driver [%s]\n", @@ -2737,8 +2729,8 @@ static uint32 set_driver_init_2(NT_PRINTER_INFO_LEVEL_2 *info_ptr) */ while ( (current=info_ptr->specific) != NULL ) { info_ptr->specific=current->next; - safe_free(current->data); - safe_free(current); + SAFE_FREE(current->data); + SAFE_FREE(current); } /* @@ -2746,7 +2738,7 @@ static uint32 set_driver_init_2(NT_PRINTER_INFO_LEVEL_2 *info_ptr) */ len += unpack_specifics(&info_ptr->specific,dbuf.dptr+len, dbuf.dsize-len); - safe_free(dbuf.dptr); + SAFE_FREE(dbuf.dptr); return True; } @@ -2827,7 +2819,7 @@ done: if (ret == -1) DEBUG(8, ("update_driver_init_2: error updating printer init to tdb on disk\n")); - safe_free(buf); + SAFE_FREE(buf); DEBUG(10,("update_driver_init_2: Saved printer [%s] init DEVMODE & specifics for driver [%s]\n", info->sharename, info->drivername)); @@ -2965,8 +2957,8 @@ static WERROR save_driver_init_2(NT_PRINTER_INFO_LEVEL *printer, NT_PRINTER_PARA done: talloc_destroy(ctx); if (nt_devmode) - safe_free(nt_devmode->private); - safe_free(nt_devmode); + SAFE_FREE(nt_devmode->private); + SAFE_FREE(nt_devmode); printer->info_2->devmode = tmp_devmode; return status; @@ -3022,7 +3014,7 @@ WERROR get_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, fstring s dump_a_printer(*printer, level); *pp_printer = printer; } else { - safe_free(printer); + SAFE_FREE(printer); } break; } @@ -3070,8 +3062,7 @@ uint32 free_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level) break; } - safe_free(printer); - *pp_printer = NULL; + SAFE_FREE(*pp_printer); return result; } @@ -3141,9 +3132,9 @@ uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level) if (driver.info_3 != NULL) { info3=driver.info_3; - safe_free(info3->dependentfiles); + SAFE_FREE(info3->dependentfiles); ZERO_STRUCTP(info3); - safe_free(info3); + SAFE_FREE(info3); result=0; } else @@ -3158,10 +3149,10 @@ uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level) if (driver.info_6 != NULL) { info6=driver.info_6; - safe_free(info6->dependentfiles); - safe_free(info6->previousnames); + SAFE_FREE(info6->dependentfiles); + SAFE_FREE(info6->previousnames); ZERO_STRUCTP(info6); - safe_free(info6); + SAFE_FREE(info6); result=0; } else @@ -3230,7 +3221,7 @@ BOOL printer_driver_in_use (char *arch, char *driver) info.datatype, info.parameters); - safe_free(dbuf.dptr); + SAFE_FREE(dbuf.dptr); if (ret == -1) { DEBUG (0,("printer_driver_in_use: tdb_unpack failed for printer %s\n", -- cgit