From 22363b9d7893998169ac7a777df466940fd0a000 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Wed, 17 Jan 2001 22:55:02 +0000 Subject: Changes from APPLIANCE_HEAD: source/include/proto.h source/include/rpc_spoolss.h source/rpc_parse/parse_spoolss.c source/rpc_server/srv_spoolss.c source/rpc_server/srv_spoolss_nt.c - speedups in printer queue enumeration - still room for improvement. The construct_dev_mode() still creates and destroys a printer info_2 structure every time it is called. - fixed job->devmode memory leak - converted printer job notification routines to use tallocated memory rather than a fixed 2K buffer. This reduces the memory requirements of a 4500 job queue enumeration from 90MB to about 16MB. (This used to be commit 7853b27bc1765d48d5f06837f8aca71a3a0d1e5d) --- source3/rpc_parse/parse_spoolss.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index a6f46285eb..868d90ae74 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -22,7 +22,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" extern int DEBUGLEVEL; @@ -384,9 +383,31 @@ BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data, return False; if (MARSHALLING(ps)) { /* These are already in little endian format. Don't byte swap. */ - if(!prs_uint8s(True,"string",ps,depth,(uint8 *)data->notify_data.data.string,x*2)) - return False; + if (x == 1) { + + /* No memory allocated for this string + therefore following the data.string + pointer is a bad idea. Use a pointer to + the uint32 length union member to + provide a source for a unicode NULL */ + + if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2)) + return False; + } else { + if(!prs_uint8s(True,"string",ps,depth,(uint8 *)data->notify_data.data.string,x*2)) + return False; + } } else { + + /* Tallocate memory for string */ + + DEBUG(0, ("** tallocating memory\n")); + + data->notify_data.data.string = (uint16 *) + talloc(ps->mem_ctx, x * 2); + if (!data->notify_data.data.string) + return False; + if(!prs_uint16s(True,"string",ps,depth,data->notify_data.data.string,x)) return False; } @@ -5753,10 +5774,7 @@ static JOB_INFO_2 *job2_dup(const JOB_INFO_2* from) void free_job_info_2(JOB_INFO_2 *job) { if (job!=NULL) - { free_devmode(job->devmode); - free(job); - } } void free_job2_array(uint32 num_entries, JOB_INFO_2 **entries) -- cgit