From fbc8c6a1096ec829f48b403239f105065bf155b1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 20 Mar 2002 22:39:30 +0000 Subject: [PATCH] Ensure we don't do lp_servicename()'s in tdb traverse as this allocates lots of memory. Jeremy. --- source/printing/printing.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/printing/printing.c b/source/printing/printing.c index febdd0eec5d..ad5acb15052 100644 --- a/source/printing/printing.c +++ b/source/printing/printing.c @@ -115,10 +115,12 @@ store a job structure back to the database static BOOL print_job_store(int jobid, struct printjob *pjob) { TDB_DATA d; + BOOL ret; + d.dptr = (void *)pjob; d.dsize = sizeof(*pjob); - - return (tdb_store(tdb, print_key(jobid), d, TDB_REPLACE) == 0); + ret = (tdb_store(tdb, print_key(jobid), d, TDB_REPLACE) == 0); + return ret; } /**************************************************************************** @@ -185,7 +187,7 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void memcpy(&jobid, key.dptr, sizeof(jobid)); memcpy(&pjob, data.dptr, sizeof(pjob)); - if (!strequal(lp_servicename(ts->snum), pjob.queuename)) { + if (ts->snum != lp_servicenumber(pjob.queuename)) { /* this isn't for the queue we are looking at */ ts->total_jobs++; return 0; @@ -1176,7 +1178,7 @@ static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void * memcpy(&pjob, data.dptr, sizeof(pjob)); /* maybe it isn't for this queue */ - if (!strequal(lp_servicename(ts->snum), pjob.queuename)) + if (ts->snum != lp_servicenumber(pjob.queuename)) return 0; if (ts->qcount >= ts->maxcount) return 0; @@ -1213,7 +1215,7 @@ static int traverse_count_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, memcpy(&pjob, data.dptr, sizeof(pjob)); /* maybe it isn't for this queue */ - if (!strequal(lp_servicename(ts->snum), pjob.queuename)) + if (ts->snum != lp_servicenumber(pjob.queuename)) return 0; ts->count++;