[poppler] poppler/poppler: Annot.cc, 1.1.1.1, 1.2 Array.cc, 1.2, 1.3 BuiltinFont.cc, 1.1.1.1, 1.2 CMap.cc, 1.1.1.1, 1.2 Catalog.cc, 1.10, 1.11 CharCodeToUnicode.cc, 1.1.1.1, 1.2 Dict.cc, 1.2, 1.3 Function.cc, 1.1.1.1, 1.2 Gfx.cc, 1.2, 1.3 GfxFont.cc, 1.3, 1.4 GfxState.cc, 1.3, 1.4 JArithmeticDecoder.cc, 1.1.1.1, 1.2 JBIG2Stream.cc, 1.1.1.1, 1.2 Link.cc, 1.1.1.1, 1.2 NameToCharCode.cc, 1.1.1.1, 1.2 Outline.cc, 1.2, 1.3 SplashOutputDev.cc, 1.2, 1.3 Stream.cc, 1.3, 1.4 TextOutputDev.cc, 1.10, 1.11 XRef.cc, 1.3, 1.4

Brad Hards bradh at freedesktop.org
Sat Aug 27 01:43:45 PDT 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv7837/poppler

Modified Files:
	Annot.cc Array.cc BuiltinFont.cc CMap.cc Catalog.cc 
	CharCodeToUnicode.cc Dict.cc Function.cc Gfx.cc GfxFont.cc 
	GfxState.cc JArithmeticDecoder.cc JBIG2Stream.cc Link.cc 
	NameToCharCode.cc Outline.cc SplashOutputDev.cc Stream.cc 
	TextOutputDev.cc XRef.cc 
Log Message:
Merge the gmalloc -> gmallocn changes from xpdf 3.0.1. This change is
based on martink's work (13-xpdf-3.01-goo-allocn.patch) with some
tweaking by me. There may be some residual gmallocn changes still to
be merged.


Index: Annot.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Annot.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Annot.cc	3 Mar 2005 19:46:01 -0000	1.1.1.1
+++ Annot.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -115,7 +115,7 @@
 	if (annot->isOk()) {
 	  if (nAnnots >= size) {
 	    size += 16;
-	    annots = (Annot **)grealloc(annots, size * sizeof(Annot *));
+	    annots = (Annot **)greallocn(annots, size, sizeof(Annot *));
 	  }
 	  annots[nAnnots++] = annot;
 	} else {

Index: Array.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Array.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Array.cc	22 Mar 2005 22:46:37 -0000	1.2
+++ Array.cc	27 Aug 2005 08:43:43 -0000	1.3
@@ -44,7 +44,7 @@
     } else {
       size *= 2;
     }
-    elems = (Object *)grealloc(elems, size * sizeof(Object));
+    elems = (Object *)greallocn(elems, size, sizeof(Object));
   }
   elems[length] = *elem;
   ++length;

Index: BuiltinFont.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/BuiltinFont.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- BuiltinFont.cc	3 Mar 2005 19:46:01 -0000	1.1.1.1
+++ BuiltinFont.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -24,7 +24,7 @@
   int i, h;
 
   size = sizeA;
-  tab = (BuiltinFontWidth **)gmalloc(size * sizeof(BuiltinFontWidth *));
+  tab = (BuiltinFontWidth **)gmallocn(size, sizeof(BuiltinFontWidth *));
   for (i = 0; i < size; ++i) {
     tab[i] = NULL;
   }

Index: CMap.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CMap.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- CMap.cc	3 Mar 2005 19:46:02 -0000	1.1.1.1
+++ CMap.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -138,7 +138,7 @@
   collection = collectionA;
   cMapName = cMapNameA;
   wMode = 0;
-  vector = (CMapVectorEntry *)gmalloc(256 * sizeof(CMapVectorEntry));
+  vector = (CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry));
   for (i = 0; i < 256; ++i) {
     vector[i].isVector = gFalse;
     vector[i].cid = 0;
@@ -182,7 +182,7 @@
       if (!dest[i].isVector) {
 	dest[i].isVector = gTrue;
 	dest[i].vector =
-	  (CMapVectorEntry *)gmalloc(256 * sizeof(CMapVectorEntry));
+	  (CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry));
 	for (j = 0; j < 256; ++j) {
 	  dest[i].vector[j].isVector = gFalse;
 	  dest[i].vector[j].cid = 0;
@@ -213,7 +213,7 @@
       if (!vec[i].isVector) {
 	vec[i].isVector = gTrue;
 	vec[i].vector =
-	  (CMapVectorEntry *)gmalloc(256 * sizeof(CMapVectorEntry));
+	  (CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry));
 	for (j = 0; j < 256; ++j) {
 	  vec[i].vector[j].isVector = gFalse;
 	  vec[i].vector[j].cid = 0;

Index: Catalog.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Catalog.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Catalog.cc	7 Jul 2005 11:04:08 -0000	1.10
+++ Catalog.cc	27 Aug 2005 08:43:43 -0000	1.11
@@ -76,8 +76,8 @@
     return;
   }
 
-  pages = (Page **)gmalloc(pagesSize * sizeof(Page *));
-  pageRefs = (Ref *)gmalloc(pagesSize * sizeof(Ref));
+  pages = (Page **)gmallocn(pagesSize, sizeof(Page *));
+  pageRefs = (Ref *)gmallocn(pagesSize,  sizeof(Ref));
   for (i = 0; i < pagesSize; ++i) {
     pages[i] = NULL;
     pageRefs[i].num = -1;
@@ -248,8 +248,8 @@
           error(-1, "Invalid 'pagesSize' parameter.");
           goto err3;
         }
-	pages = (Page **)grealloc(pages, pagesSize * sizeof(Page *));
-	pageRefs = (Ref *)grealloc(pageRefs, pagesSize * sizeof(Ref));
+	pages = (Page **)greallocn(pages, pagesSize, sizeof(Page *));
+	pageRefs = (Ref *)greallocn(pageRefs, pagesSize, sizeof(Ref));
 	for (j = pagesSize - 32; j < pagesSize; ++j) {
 	  pages[j] = NULL;
 	  pageRefs[j].num = -1;

Index: CharCodeToUnicode.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CharCodeToUnicode.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- CharCodeToUnicode.cc	3 Mar 2005 19:46:02 -0000	1.1.1.1
+++ CharCodeToUnicode.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -70,13 +70,13 @@
   }
 
   size = 32768;
-  mapA = (Unicode *)gmalloc(size * sizeof(Unicode));
+  mapA = (Unicode *)gmallocn(size, sizeof(Unicode));
   mapLenA = 0;
 
   while (getLine(buf, sizeof(buf), f)) {
     if (mapLenA == size) {
       size *= 2;
-      mapA = (Unicode *)grealloc(mapA, size * sizeof(Unicode));
+      mapA = (Unicode *)greallocn(mapA, size, sizeof(Unicode));
     }
     if (sscanf(buf, "%x", &u) == 1) {
       mapA[mapLenA] = u;
@@ -115,7 +115,7 @@
   }
 
   size = 4096;
-  mapA = (Unicode *)gmalloc(size * sizeof(Unicode));
+  mapA = (Unicode *)gmallocn(size, sizeof(Unicode));
   memset(mapA, 0, size * sizeof(Unicode));
   len = 0;
   sMapA = NULL;
@@ -152,7 +152,7 @@
       while (u0 >= size) {
 	size *= 2;
       }
-      mapA = (Unicode *)grealloc(mapA, size * sizeof(Unicode));
+      mapA = (Unicode *)greallocn(mapA, size, sizeof(Unicode));
       memset(mapA + oldSize, 0, (size - oldSize) * sizeof(Unicode));
     }
     if (n == 1) {
@@ -162,7 +162,7 @@
       if (sMapLenA == sMapSizeA) {
 	sMapSizeA += 16;
 	sMapA = (CharCodeToUnicodeString *)
-	          grealloc(sMapA, sMapSizeA * sizeof(CharCodeToUnicodeString));
+	          greallocn(sMapA, sMapSizeA, sizeof(CharCodeToUnicodeString));
       }
       sMapA[sMapLenA].c = u0;
       for (i = 0; i < n; ++i) {
@@ -320,7 +320,7 @@
   if (code >= mapLen) {
     oldLen = mapLen;
     mapLen = (code + 256) & ~255;
-    map = (Unicode *)grealloc(map, mapLen * sizeof(Unicode));
+    map = (Unicode *)greallocn(map, mapLen, sizeof(Unicode));
     for (i = oldLen; i < mapLen; ++i) {
       map[i] = 0;
     }
@@ -335,7 +335,7 @@
     if (sMapLen >= sMapSize) {
       sMapSize = sMapSize + 16;
       sMap = (CharCodeToUnicodeString *)
-	       grealloc(sMap, sMapSize * sizeof(CharCodeToUnicodeString));
+	       greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
     }
     map[code] = 0;
     sMap[sMapLen].c = code;
@@ -357,7 +357,7 @@
 
   tag = tagA;
   mapLen = 256;
-  map = (Unicode *)gmalloc(mapLen * sizeof(Unicode));
+  map = (Unicode *)gmallocn(mapLen, sizeof(Unicode));
   for (i = 0; i < mapLen; ++i) {
     map[i] = 0;
   }
@@ -376,7 +376,7 @@
   tag = tagA;
   mapLen = mapLenA;
   if (copyMap) {
-    map = (Unicode *)gmalloc(mapLen * sizeof(Unicode));
+    map = (Unicode *)gmallocn(mapLen, sizeof(Unicode));
     memcpy(map, mapA, mapLen * sizeof(Unicode));
   } else {
     map = mapA;
@@ -442,7 +442,7 @@
     if (sMapLen == sMapSize) {
       sMapSize += 8;
       sMap = (CharCodeToUnicodeString *)
-	       grealloc(sMap, sMapSize * sizeof(CharCodeToUnicodeString));
+	       greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
     }
     sMap[sMapLen].c = c;
     sMap[sMapLen].len = len;
@@ -480,7 +480,7 @@
   int i;
 
   size = sizeA;
-  cache = (CharCodeToUnicode **)gmalloc(size * sizeof(CharCodeToUnicode *));
+  cache = (CharCodeToUnicode **)gmallocn(size, sizeof(CharCodeToUnicode *));
   for (i = 0; i < size; ++i) {
     cache[i] = NULL;
   }

Index: Dict.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Dict.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Dict.cc	28 Mar 2005 07:49:55 -0000	1.2
+++ Dict.cc	27 Aug 2005 08:43:43 -0000	1.3
@@ -47,7 +47,7 @@
     } else {
       size *= 2;
     }
-    entries = (DictEntry *)grealloc(entries, size * sizeof(DictEntry));
+    entries = (DictEntry *)greallocn(entries, size, sizeof(DictEntry));
   }
   entries[length].key = key;
   entries[length].val = *val;

Index: Function.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Function.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Function.cc	3 Mar 2005 19:46:00 -0000	1.1.1.1
+++ Function.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -297,7 +297,7 @@
   nSamples = n;
   for (i = 0; i < m; ++i)
     nSamples *= sampleSize[i];
-  samples = (double *)gmalloc(nSamples * sizeof(double));
+  samples = (double *)gmallocn(nSamples, sizeof(double));
   buf = 0;
   bits = 0;
   bitMask = (1 << sampleBits) - 1;
@@ -351,7 +351,7 @@
   for (i = 0; i < m; ++i) {
     nSamples *= sampleSize[i];
   }
-  samples = (double *)gmalloc(nSamples * sizeof(double));
+  samples = (double *)gmallocn(nSamples, sizeof(double));
   memcpy(samples, func->samples, nSamples * sizeof(double));
 }
 
@@ -554,9 +554,9 @@
     goto err1;
   }
   k = obj1.arrayGetLength();
-  funcs = (Function **)gmalloc(k * sizeof(Function *));
-  bounds = (double *)gmalloc((k + 1) * sizeof(double));
-  encode = (double *)gmalloc(2 * k * sizeof(double));
+  funcs = (Function **)gmallocn(k, sizeof(Function *));
+  bounds = (double *)gmallocn(k + 1, sizeof(double));
+  encode = (double *)gmallocn(2 * k, sizeof(double));
   for (i = 0; i < k; ++i) {
     funcs[i] = NULL;
   }
@@ -620,13 +620,13 @@
   int i;
 
   k = func->k;
-  funcs = (Function **)gmalloc(k * sizeof(Function *));
+  funcs = (Function **)gmallocn(k, sizeof(Function *));
   for (i = 0; i < k; ++i) {
     funcs[i] = func->funcs[i]->copy();
   }
-  bounds = (double *)gmalloc((k + 1) * sizeof(double));
+  bounds = (double *)gmallocn(k + 1, sizeof(double));
   memcpy(bounds, func->bounds, (k + 1) * sizeof(double));
-  encode = (double *)gmalloc(2 * k * sizeof(double));
+  encode = (double *)gmallocn(2 * k, sizeof(double));
   memcpy(encode, func->encode, 2 * k * sizeof(double));
   ok = gTrue;
 }
@@ -1016,7 +1016,7 @@
 
 PostScriptFunction::PostScriptFunction(PostScriptFunction *func) {
   memcpy(this, func, sizeof(PostScriptFunction));
-  code = (PSObject *)gmalloc(codeSize * sizeof(PSObject));
+  code = (PSObject *)gmallocn(codeSize, sizeof(PSObject));
   memcpy(code, func->code, codeSize * sizeof(PSObject));
 }
 
@@ -1207,7 +1207,7 @@
 void PostScriptFunction::resizeCode(int newSize) {
   if (newSize >= codeSize) {
     codeSize += 64;
-    code = (PSObject *)grealloc(code, codeSize * sizeof(PSObject));
+    code = (PSObject *)greallocn(code, codeSize, sizeof(PSObject));
   }
 }
 

Index: Gfx.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Gfx.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Gfx.cc	23 Aug 2005 18:20:45 -0000	1.2
+++ Gfx.cc	27 Aug 2005 08:43:43 -0000	1.3
@@ -764,7 +764,7 @@
   if (length == 0) {
     dash = NULL;
   } else {
-    dash = (double *)gmalloc(length * sizeof(double));
+    dash = (double *)gmallocn(length, sizeof(double));
     for (i = 0; i < length; ++i) {
       dash[i] = a->get(i, &obj)->getNum();
       obj.free();

Index: GfxFont.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxFont.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- GfxFont.cc	17 Aug 2005 16:54:01 -0000	1.3
+++ GfxFont.cc	27 Aug 2005 08:43:43 -0000	1.4
@@ -940,7 +940,7 @@
   Unicode u;
   int code, i, n;
 
-  map = (Gushort *)gmalloc(256 * sizeof(Gushort));
+  map = (Gushort *)gmallocn(256, sizeof(Gushort));
   for (i = 0; i < 256; ++i) {
     map[i] = 0;
   }
@@ -1198,13 +1198,13 @@
     if (obj1.isStream()) {
       cidToGIDLen = 0;
       i = 64;
-      cidToGID = (Gushort *)gmalloc(i * sizeof(Gushort));
+      cidToGID = (Gushort *)gmallocn(i, sizeof(Gushort));
       obj1.streamReset();
       while ((c1 = obj1.streamGetChar()) != EOF &&
 	     (c2 = obj1.streamGetChar()) != EOF) {
 	if (cidToGIDLen == i) {
 	  i *= 2;
-	  cidToGID = (Gushort *)grealloc(cidToGID, i * sizeof(Gushort));
+	  cidToGID = (Gushort *)greallocn(cidToGID, i, sizeof(Gushort));
 	}
 	cidToGID[cidToGIDLen++] = (Gushort)((c1 << 8) + c2);
       }
@@ -1234,8 +1234,8 @@
 	  if (widths.nExceps == excepsSize) {
 	    excepsSize += 16;
 	    widths.exceps = (GfxFontCIDWidthExcep *)
-	      grealloc(widths.exceps,
-		       excepsSize * sizeof(GfxFontCIDWidthExcep));
+	      greallocn(widths.exceps,
+			excepsSize, sizeof(GfxFontCIDWidthExcep));
 	  }
 	  widths.exceps[widths.nExceps].first = obj2.getInt();
 	  widths.exceps[widths.nExceps].last = obj3.getInt();
@@ -1250,8 +1250,8 @@
 	if (widths.nExceps + obj3.arrayGetLength() > excepsSize) {
 	  excepsSize = (widths.nExceps + obj3.arrayGetLength() + 15) & ~15;
 	  widths.exceps = (GfxFontCIDWidthExcep *)
-	    grealloc(widths.exceps,
-		     excepsSize * sizeof(GfxFontCIDWidthExcep));
+	    greallocn(widths.exceps,
+		      excepsSize, sizeof(GfxFontCIDWidthExcep));
 	}
 	j = obj2.getInt();
 	for (k = 0; k < obj3.arrayGetLength(); ++k) {
@@ -1307,8 +1307,8 @@
 	  if (widths.nExcepsV == excepsSize) {
 	    excepsSize += 16;
 	    widths.excepsV = (GfxFontCIDWidthExcepV *)
-	      grealloc(widths.excepsV,
-		       excepsSize * sizeof(GfxFontCIDWidthExcepV));
+	      greallocn(widths.excepsV,
+			excepsSize, sizeof(GfxFontCIDWidthExcepV));
 	  }
 	  widths.excepsV[widths.nExcepsV].first = obj2.getInt();
 	  widths.excepsV[widths.nExcepsV].last = obj3.getInt();
@@ -1328,8 +1328,8 @@
 	  excepsSize =
 	    (widths.nExcepsV + obj3.arrayGetLength() / 3 + 15) & ~15;
 	  widths.excepsV = (GfxFontCIDWidthExcepV *)
-	    grealloc(widths.excepsV,
-		     excepsSize * sizeof(GfxFontCIDWidthExcepV));
+	    greallocn(widths.excepsV,
+		      excepsSize, sizeof(GfxFontCIDWidthExcepV));
 	}
 	j = obj2.getInt();
 	for (k = 0; k < obj3.arrayGetLength(); k += 3) {
@@ -1492,7 +1492,7 @@
   Ref r;
 
   numFonts = fontDict->getLength();
-  fonts = (GfxFont **)gmalloc(numFonts * sizeof(GfxFont *));
+  fonts = (GfxFont **)gmallocn(numFonts, sizeof(GfxFont *));
   for (i = 0; i < numFonts; ++i) {
     fontDict->getValNF(i, &obj1);
     obj1.fetch(xref, &obj2);

Index: GfxState.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxState.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- GfxState.cc	5 Aug 2005 22:30:20 -0000	1.3
+++ GfxState.cc	27 Aug 2005 08:43:43 -0000	1.4
@@ -907,8 +907,8 @@
 					   int indexHighA) {
   base = baseA;
   indexHigh = indexHighA;
-  lookup = (Guchar *)gmalloc((indexHigh + 1) * base->getNComps() *
-			     sizeof(Guchar));
+  lookup = (Guchar *)gmallocn((indexHigh + 1) * base->getNComps(),
+			      sizeof(Guchar));
 }
 
 GfxIndexedColorSpace::~GfxIndexedColorSpace() {
@@ -2176,7 +2176,7 @@
     colorSpace2 = indexedCS->getBase();
     indexHigh = indexedCS->getIndexHigh();
     nComps2 = colorSpace2->getNComps();
-    lookup = (double *)gmalloc((maxPixel + 1) * nComps2 * sizeof(double));
+    lookup = (double *)gmallocn((maxPixel + 1) * nComps2, sizeof(double));
     lookup2 = indexedCS->getLookup();
     colorSpace2->getDefaultRanges(x, y, indexHigh);
     byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2);
@@ -2200,8 +2200,8 @@
     sepCS = (GfxSeparationColorSpace *)colorSpace;
     colorSpace2 = sepCS->getAlt();
     nComps2 = colorSpace2->getNComps();
-    lookup = (double *)gmalloc((maxPixel + 1) * nComps2 * sizeof(double));
-    byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2);
+    lookup = (double *)gmallocn((maxPixel + 1) * nComps2, sizeof(double));
+    byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps2);
     sepFunc = sepCS->getFunc();
     for (i = 0; i <= maxPixel; ++i) {
       x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
@@ -2212,8 +2212,8 @@
       }
     }
   } else {
-    lookup = (double *)gmalloc((maxPixel + 1) * nComps * sizeof(double));
-    byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps);
+    lookup = (double *)gmallocn((maxPixel + 1) * nComps, sizeof(double));
+    byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps);
 
     for (i = 0; i <= maxPixel; ++i) {
       for (k = 0; k < nComps; ++k) {
@@ -2380,9 +2380,9 @@
 
 GfxSubpath::GfxSubpath(double x1, double y1) {
   size = 16;
-  x = (double *)gmalloc(size * sizeof(double));
-  y = (double *)gmalloc(size * sizeof(double));
-  curve = (GBool *)gmalloc(size * sizeof(GBool));
+  x = (double *)gmallocn(size, sizeof(double));
+  y = (double *)gmallocn(size, sizeof(double));
+  curve = (GBool *)gmallocn(size, sizeof(GBool));
   n = 1;
   x[0] = x1;
   y[0] = y1;
@@ -2400,9 +2400,9 @@
 GfxSubpath::GfxSubpath(GfxSubpath *subpath) {
   size = subpath->size;
   n = subpath->n;
-  x = (double *)gmalloc(size * sizeof(double));
-  y = (double *)gmalloc(size * sizeof(double));
-  curve = (GBool *)gmalloc(size * sizeof(GBool));
+  x = (double *)gmallocn(size, sizeof(double));
+  y = (double *)gmallocn(size, sizeof(double));
+  curve = (GBool *)gmallocn(size, sizeof(GBool));
   memcpy(x, subpath->x, n * sizeof(double));
   memcpy(y, subpath->y, n * sizeof(double));
   memcpy(curve, subpath->curve, n * sizeof(GBool));
@@ -2412,9 +2412,9 @@
 void GfxSubpath::lineTo(double x1, double y1) {
   if (n >= size) {
     size += 16;
-    x = (double *)grealloc(x, size * sizeof(double));
-    y = (double *)grealloc(y, size * sizeof(double));
-    curve = (GBool *)grealloc(curve, size * sizeof(GBool));
+    x = (double *)greallocn(x, size, sizeof(double));
+    y = (double *)greallocn(y, size, sizeof(double));
+    curve = (GBool *)greallocn(curve, size, sizeof(GBool));
   }
   x[n] = x1;
   y[n] = y1;
@@ -2426,9 +2426,9 @@
 			 double x3, double y3) {
   if (n+3 > size) {
     size += 16;
-    x = (double *)grealloc(x, size * sizeof(double));
-    y = (double *)grealloc(y, size * sizeof(double));
-    curve = (GBool *)grealloc(curve, size * sizeof(GBool));
+    x = (double *)greallocn(x, size, sizeof(double));
+    y = (double *)greallocn(y, size, sizeof(double));
+    curve = (GBool *)greallocn(curve, size, sizeof(GBool));
   }
   x[n] = x1;
   y[n] = y1;
@@ -2462,7 +2462,7 @@
   size = 16;
   n = 0;
   firstX = firstY = 0;
-  subpaths = (GfxSubpath **)gmalloc(size * sizeof(GfxSubpath *));
+  subpaths = (GfxSubpath **)gmallocn(size, sizeof(GfxSubpath *));
 }
 
 GfxPath::~GfxPath() {
@@ -2483,7 +2483,7 @@
   firstY = firstY1;
   size = size1;
   n = n1;
-  subpaths = (GfxSubpath **)gmalloc(size * sizeof(GfxSubpath *));
+  subpaths = (GfxSubpath **)gmallocn(size, sizeof(GfxSubpath *));
   for (i = 0; i < n; ++i)
     subpaths[i] = subpaths1[i]->copy();
 }
@@ -2499,7 +2499,7 @@
     if (n >= size) {
       size += 16;
       subpaths = (GfxSubpath **)
-	           grealloc(subpaths, size * sizeof(GfxSubpath *));
+	           greallocn(subpaths, size, sizeof(GfxSubpath *));
     }
     subpaths[n] = new GfxSubpath(firstX, firstY);
     ++n;
@@ -2513,8 +2513,8 @@
   if (justMoved) {
     if (n >= size) {
       size += 16;
-      subpaths = (GfxSubpath **)
-	           grealloc(subpaths, size * sizeof(GfxSubpath *));
+      subpaths = (GfxSubpath **) 
+ 	         greallocn(subpaths, size, sizeof(GfxSubpath *));
     }
     subpaths[n] = new GfxSubpath(firstX, firstY);
     ++n;
@@ -2530,7 +2530,7 @@
     if (n >= size) {
       size += 16;
       subpaths = (GfxSubpath **)
-	           grealloc(subpaths, size * sizeof(GfxSubpath *));
+	greallocn(subpaths, size, sizeof(GfxSubpath *));
     }
     subpaths[n] = new GfxSubpath(firstX, firstY);
     ++n;
@@ -2545,7 +2545,7 @@
   if (n + path->n > size) {
     size = n + path->n;
     subpaths = (GfxSubpath **)
-                 grealloc(subpaths, size * sizeof(GfxSubpath *));
+                 greallocn(subpaths, size, sizeof(GfxSubpath *));
   }
   for (i = 0; i < path->n; ++i) {
     subpaths[n++] = path->subpaths[i]->copy();
@@ -2694,7 +2694,7 @@
     strokePattern = state->strokePattern->copy();
   }
   if (lineDashLength > 0) {
-    lineDash = (double *)gmalloc(lineDashLength * sizeof(double));
+    lineDash = (double *)gmallocn(lineDashLength, sizeof(double));
     memcpy(lineDash, state->lineDash, lineDashLength * sizeof(double));
   }
   saved = NULL;

Index: JArithmeticDecoder.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/JArithmeticDecoder.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- JArithmeticDecoder.cc	3 Mar 2005 19:46:03 -0000	1.1.1.1
+++ JArithmeticDecoder.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -22,7 +22,7 @@
 
 JArithmeticDecoderStats::JArithmeticDecoderStats(int contextSizeA) {
   contextSize = contextSizeA;
-  cxTab = (Guchar *)gmalloc(contextSize * sizeof(Guchar));
+  cxTab = (Guchar *)gmallocn(contextSize, sizeof(Guchar));
   reset();
 }
 

Index: JBIG2Stream.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/JBIG2Stream.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- JBIG2Stream.cc	3 Mar 2005 19:46:03 -0000	1.1.1.1
+++ JBIG2Stream.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -993,7 +993,7 @@
   JBIG2Segment(segNumA)
 {
   size = sizeA;
-  bitmaps = (JBIG2Bitmap **)gmalloc(size * sizeof(JBIG2Bitmap *));
+  bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *));
   genericRegionStats = NULL;
   refinementRegionStats = NULL;
 }
@@ -1037,7 +1037,7 @@
   JBIG2Segment(segNumA)
 {
   size = sizeA;
-  bitmaps = (JBIG2Bitmap **)gmalloc(size * sizeof(JBIG2Bitmap *));
+  bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *));
 }
 
 JBIG2PatternDict::~JBIG2PatternDict() {
@@ -1233,7 +1233,7 @@
     }
 
     // referred-to segment numbers
-    refSegs = (Guint *)gmalloc(nRefSegs * sizeof(Guint));
+    refSegs = (Guint *)gmallocn(nRefSegs, sizeof(Guint));
     if (segNum <= 256) {
       for (i = 0; i < nRefSegs; ++i) {
 	if (!readUByte(&refSegs[i])) {
@@ -1451,8 +1451,8 @@
   }
 
   // get the input symbol bitmaps
-  bitmaps = (JBIG2Bitmap **)gmalloc((numInputSyms + numNewSyms) *
-				    sizeof(JBIG2Bitmap *));
+  bitmaps = (JBIG2Bitmap **)gmallocn(numInputSyms + numNewSyms,
+				     sizeof(JBIG2Bitmap *));
   k = 0;
   inputSymbolDict = NULL;
   for (i = 0; i < nRefSegs; ++i) {
@@ -1527,7 +1527,7 @@
   // allocate symbol widths storage
   symWidths = NULL;
   if (huff && !refAgg) {
-    symWidths = (Guint *)gmalloc(numNewSyms * sizeof(Guint));
+    symWidths = (Guint *)gmallocn(numNewSyms, sizeof(Guint));
   }
 
   symHeight = 0;
@@ -1788,7 +1788,7 @@
   }
 
   // get the symbol bitmaps
-  syms = (JBIG2Bitmap **)gmalloc(numSyms * sizeof(JBIG2Bitmap *));
+  syms = (JBIG2Bitmap **)gmallocn(numSyms, sizeof(JBIG2Bitmap *));
   kk = 0;
   for (i = 0; i < nRefSegs; ++i) {
     seg = findSegment(refSegs[i]);
@@ -1888,8 +1888,8 @@
     runLengthTab[35].prefixLen = 0;
     runLengthTab[35].rangeLen = jbig2HuffmanEOT;
     huffDecoder->buildTable(runLengthTab, 35);
-    symCodeTab = (JBIG2HuffmanTable *)gmalloc((numSyms + 1) *
-					      sizeof(JBIG2HuffmanTable));
+    symCodeTab = (JBIG2HuffmanTable *)gmallocn(numSyms + 1,
+					       sizeof(JBIG2HuffmanTable));
     for (i = 0; i < numSyms; ++i) {
       symCodeTab[i].val = i;
       symCodeTab[i].rangeLen = 0;
@@ -2298,7 +2298,7 @@
   }
 
   // read the gray-scale image
-  grayImg = (Guint *)gmalloc(gridW * gridH * sizeof(Guint));
+  grayImg = (Guint *)gmallocn(gridW * gridH, sizeof(Guint));
   memset(grayImg, 0, gridW * gridH * sizeof(Guint));
   atx[0] = templ <= 1 ? 3 : 2;  aty[0] = -1;
   atx[1] = -3;                  aty[1] = -1;
@@ -2451,8 +2451,8 @@
   if (mmr) {
 
     mmrDecoder->reset();
-    refLine = (int *)gmalloc((w + 2) * sizeof(int));
-    codingLine = (int *)gmalloc((w + 2) * sizeof(int));
+    refLine = (int *)gmallocn(w + 2, sizeof(int));
+    codingLine = (int *)gmallocn(w + 2, sizeof(int));
     codingLine[0] = codingLine[1] = w;
 
     for (y = 0; y < h; ++y) {
@@ -3111,14 +3111,14 @@
   huffDecoder->reset();
   huffTabSize = 8;
   huffTab = (JBIG2HuffmanTable *)
-                gmalloc(huffTabSize * sizeof(JBIG2HuffmanTable));
+                gmallocn(huffTabSize, sizeof(JBIG2HuffmanTable));
   i = 0;
   val = lowVal;
   while (val < highVal) {
     if (i == huffTabSize) {
       huffTabSize *= 2;
       huffTab = (JBIG2HuffmanTable *)
-	            grealloc(huffTab, huffTabSize * sizeof(JBIG2HuffmanTable));
+	            greallocn(huffTab, huffTabSize, sizeof(JBIG2HuffmanTable));
     }
     huffTab[i].val = val;
     huffTab[i].prefixLen = huffDecoder->readBits(prefixBits);
@@ -3129,7 +3129,7 @@
   if (i + oob + 3 > huffTabSize) {
     huffTabSize = i + oob + 3;
     huffTab = (JBIG2HuffmanTable *)
-                  grealloc(huffTab, huffTabSize * sizeof(JBIG2HuffmanTable));
+                  greallocn(huffTab, huffTabSize, sizeof(JBIG2HuffmanTable));
   }
   huffTab[i].val = lowVal - 1;
   huffTab[i].prefixLen = huffDecoder->readBits(prefixBits);

Index: Link.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Link.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Link.cc	3 Mar 2005 19:46:03 -0000	1.1.1.1
+++ Link.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -692,7 +692,7 @@
     obj2.free();
     if (obj1.dictLookup("D", &obj2)->isArray()) {
       borderDashLength = obj2.arrayGetLength();
-      borderDash = (double *)gmalloc(borderDashLength * sizeof(double));
+      borderDash = (double *)gmallocn(borderDashLength, sizeof(double));
       for (i = 0; i < borderDashLength; ++i) {
 	if (obj2.arrayGet(i, &obj3)->isNum()) {
 	  borderDash[i] = obj3.getNum();
@@ -715,7 +715,7 @@
 	  if (obj1.arrayGet(3, &obj2)->isArray()) {
 	    borderType = linkBorderDashed;
 	    borderDashLength = obj2.arrayGetLength();
-	    borderDash = (double *)gmalloc(borderDashLength * sizeof(double));
+	    borderDash = (double *)gmallocn(borderDashLength, sizeof(double));
 	    for (i = 0; i < borderDashLength; ++i) {
 	      if (obj2.arrayGet(i, &obj3)->isNum()) {
 		borderDash[i] = obj3.getNum();
@@ -807,7 +807,7 @@
 	  if (link->isOk()) {
 	    if (numLinks >= size) {
 	      size += 16;
-	      links = (Link **)grealloc(links, size * sizeof(Link *));
+	      links = (Link **)greallocn(links, size, sizeof(Link *));
 	    }
 	    links[numLinks++] = link;
 	  } else {

Index: NameToCharCode.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/NameToCharCode.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- NameToCharCode.cc	3 Mar 2005 19:46:03 -0000	1.1.1.1
+++ NameToCharCode.cc	27 Aug 2005 08:43:43 -0000	1.2
@@ -30,7 +30,7 @@
 
   size = 31;
   len = 0;
-  tab = (NameToCharCodeEntry *)gmalloc(size * sizeof(NameToCharCodeEntry));
+  tab = (NameToCharCodeEntry *)gmallocn(size, sizeof(NameToCharCodeEntry));
   for (i = 0; i < size; ++i) {
     tab[i].name = NULL;
   }
@@ -56,7 +56,7 @@
     oldSize = size;
     oldTab = tab;
     size = 2*size + 1;
-    tab = (NameToCharCodeEntry *)gmalloc(size * sizeof(NameToCharCodeEntry));
+    tab = (NameToCharCodeEntry *)gmallocn(size, sizeof(NameToCharCodeEntry));
     for (h = 0; h < size; ++h) {
       tab[h].name = NULL;
     }

Index: Outline.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Outline.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Outline.cc	21 Apr 2005 19:50:45 -0000	1.2
+++ Outline.cc	27 Aug 2005 08:43:43 -0000	1.3
@@ -58,14 +58,14 @@
     if ((s->getChar(0) & 0xff) == 0xfe &&
 	(s->getChar(1) & 0xff) == 0xff) {
       titleLen = (s->getLength() - 2) / 2;
-      title = (Unicode *)gmalloc(titleLen * sizeof(Unicode));
+      title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
       for (i = 0; i < titleLen; ++i) {
 	title[i] = ((s->getChar(2 + 2*i) & 0xff) << 8) |
 	           (s->getChar(3 + 2*i) & 0xff);
       }
     } else {
       titleLen = s->getLength();
-      title = (Unicode *)gmalloc(titleLen * sizeof(Unicode));
+      title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
       for (i = 0; i < titleLen; ++i) {
 	title[i] = pdfDocEncoding[s->getChar(i) & 0xff];
       }

Index: SplashOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/SplashOutputDev.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SplashOutputDev.cc	28 Jul 2005 17:34:19 -0000	1.2
+++ SplashOutputDev.cc	27 Aug 2005 08:43:43 -0000	1.3
@@ -126,9 +126,9 @@
   } else {
     cacheSets = 1;
   }
-  cacheData = (Guchar *)gmalloc(cacheSets * cacheAssoc * glyphSize);
-  cacheTags = (T3FontCacheTag *)gmalloc(cacheSets * cacheAssoc *
-					sizeof(T3FontCacheTag));
+  cacheData = (Guchar *)gmallocn(cacheSets * cacheAssoc, glyphSize);
+  cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc,
+					 sizeof(T3FontCacheTag));
   for (i = 0; i < cacheSets * cacheAssoc; ++i) {
     cacheTags[i].mru = i & (cacheAssoc - 1);
   }
@@ -592,7 +592,7 @@
       break;
     case fontCIDType2:
       n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
-      codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));
+      codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
       memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
 	     n * sizeof(Gushort));
       if (!(fontFile = fontEngine->loadTrueTypeFont(

Index: Stream.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Stream.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Stream.cc	27 Apr 2005 20:56:18 -0000	1.3
+++ Stream.cc	27 Aug 2005 08:43:43 -0000	1.4
@@ -337,7 +337,7 @@
   } else {
     imgLineSize = nVals;
   }
-  imgLine = (Guchar *)gmalloc(imgLineSize * sizeof(Guchar));
+  imgLine = (Guchar *)gmallocn(imgLineSize, sizeof(Guchar));
   imgIdx = nVals;
 }
 
@@ -1271,8 +1271,8 @@
   rows = rowsA;
   endOfBlock = endOfBlockA;
   black = blackA;
-  refLine = (short *)gmalloc((columns + 3) * sizeof(short));
-  codingLine = (short *)gmalloc((columns + 2) * sizeof(short));
+  refLine = (short *)gmallocn(columns + 3, sizeof(short));
+  codingLine = (short *)gmallocn(columns + 2, sizeof(short));
 
   eof = gFalse;
   row = 0;
@@ -1945,7 +1945,7 @@
     bufWidth = ((width + mcuWidth - 1) / mcuWidth) * mcuWidth;
     bufHeight = ((height + mcuHeight - 1) / mcuHeight) * mcuHeight;
     for (i = 0; i < numComps; ++i) {
-      frameBuf[i] = (int *)gmalloc(bufWidth * bufHeight * sizeof(int));
+      frameBuf[i] = (int *)gmallocn(bufWidth * bufHeight, sizeof(int));
       memset(frameBuf[i], 0, bufWidth * bufHeight * sizeof(int));
     }
 
@@ -1970,7 +1970,7 @@
     bufWidth = ((width + mcuWidth - 1) / mcuWidth) * mcuWidth;
     for (i = 0; i < numComps; ++i) {
       for (j = 0; j < mcuHeight; ++j) {
-	rowBuf[i][j] = (Guchar *)gmalloc(bufWidth * sizeof(Guchar));
+	rowBuf[i][j] = (Guchar *)gmallocn(bufWidth, sizeof(Guchar));
       }
     }
 
@@ -3651,7 +3651,7 @@
 
   // allocate the table
   tabSize = 1 << tab->maxLen;
-  tab->codes = (FlateCode *)gmalloc(tabSize * sizeof(FlateCode));
+  tab->codes = (FlateCode *)gmallocn(tabSize, sizeof(FlateCode));
 
   // clear the table
   for (i = 0; i < tabSize; ++i) {

Index: TextOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/TextOutputDev.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- TextOutputDev.cc	24 Aug 2005 18:57:46 -0000	1.10
+++ TextOutputDev.cc	27 Aug 2005 08:43:43 -0000	1.11
@@ -238,9 +238,9 @@
 		       double dx, double dy, CharCode c, Unicode u) {
   if (len == size) {
     size += 16;
-    text = (Unicode *)grealloc(text, size * sizeof(Unicode));
-    charcode = (Unicode *)grealloc(charcode, size * sizeof(CharCode));
-    edge = (double *)grealloc(edge, (size + 1) * sizeof(double));
+    text = (Unicode *)greallocn(text, size, sizeof(Unicode));
+    charcode = (Unicode *)greallocn(charcode, size, sizeof(CharCode));
+    edge = (double *)greallocn(edge, (size + 1), sizeof(double));
   }
   text[len] = u;
   charcode[len] = c;
@@ -294,9 +294,9 @@
   }
   if (len + word->len > size) {
     size = len + word->len;
-    text = (Unicode *)grealloc(text, size * sizeof(Unicode));
-    charcode = (CharCode *)grealloc(charcode, (size + 1) * sizeof(CharCode));
-    edge = (double *)grealloc(edge, (size + 1) * sizeof(double));
+    text = (Unicode *)greallocn(text, size, sizeof(Unicode));
+    charcode = (CharCode *)greallocn(charcode, (size + 1), sizeof(CharCode));
+    edge = (double *)greallocn(edge, (size + 1), sizeof(double));
   }
   for (i = 0; i < word->len; ++i) {
     text[len + i] = word->text[i];
@@ -432,15 +432,15 @@
   if (minBaseIdx > maxBaseIdx) {
     minBaseIdx = wordBaseIdx - 128;
     maxBaseIdx = wordBaseIdx + 128;
-    pool = (TextWord **)gmalloc((maxBaseIdx - minBaseIdx + 1) *
-				sizeof(TextWord *));
+    pool = (TextWord **)gmallocn(maxBaseIdx - minBaseIdx + 1,
+				 sizeof(TextWord *));
     for (baseIdx = minBaseIdx; baseIdx <= maxBaseIdx; ++baseIdx) {
       pool[baseIdx - minBaseIdx] = NULL;
     }
   } else if (wordBaseIdx < minBaseIdx) {
     newMinBaseIdx = wordBaseIdx - 128;
-    newPool = (TextWord **)gmalloc((maxBaseIdx - newMinBaseIdx + 1) *
-				   sizeof(TextWord *));
+    newPool = (TextWord **)gmallocn(maxBaseIdx - newMinBaseIdx + 1,
+				    sizeof(TextWord *));
     for (baseIdx = newMinBaseIdx; baseIdx < minBaseIdx; ++baseIdx) {
       newPool[baseIdx - newMinBaseIdx] = NULL;
     }
@@ -451,8 +451,8 @@
     minBaseIdx = newMinBaseIdx;
   } else if (wordBaseIdx > maxBaseIdx) {
     newMaxBaseIdx = wordBaseIdx + 128;
-    pool = (TextWord **)grealloc(pool, (newMaxBaseIdx - minBaseIdx + 1) *
-				         sizeof(TextWord *));
+    pool = (TextWord **)greallocn(pool, newMaxBaseIdx - minBaseIdx + 1,
+				  sizeof(TextWord *));
     for (baseIdx = maxBaseIdx + 1; baseIdx <= newMaxBaseIdx; ++baseIdx) {
       pool[baseIdx - minBaseIdx] = NULL;
     }
@@ -674,8 +674,8 @@
       ++len;
     }
   }
-  text = (Unicode *)gmalloc(len * sizeof(Unicode));
-  edge = (double *)gmalloc((len + 1) * sizeof(double));
+  text = (Unicode *)gmallocn(len, sizeof(Unicode));
+  edge = (double *)gmallocn(len + 1, sizeof(double));
   i = 0;
   for (word1 = words; word1; word1 = word1->next) {
     for (j = 0; j < word1->len; ++j) {
@@ -691,7 +691,7 @@
   }
 
   // compute convertedLen and set up the col array
-  col = (int *)gmalloc((len + 1) * sizeof(int));
+  col = (int *)gmallocn(len + 1, sizeof(int));
   convertedLen = 0;
   for (i = 0; i < len; ++i) {
     col[i] = convertedLen;
@@ -1196,7 +1196,7 @@
   }
 
   // sort lines into xy order for column assignment
-  lineArray = (TextLine **)gmalloc(nLines * sizeof(TextLine *));
+  lineArray = (TextLine **)gmallocn(nLines, sizeof(TextLine *));
   for (line = lines, i = 0; line; line = line->next, ++i) {
     lineArray[i] = line;
   }
@@ -1544,7 +1544,7 @@
 	}
       }
     }
-    wordArray = (TextWord **)gmalloc(nWords * sizeof(TextWord *));
+    wordArray = (TextWord **)gmallocn(nWords, sizeof(TextWord *));
     i = 0;
     for (flow = text->flows; flow; flow = flow->next) {
       for (blk = flow->blocks; blk; blk = blk->next) {
@@ -2371,7 +2371,7 @@
   //----- column assignment
 
   // sort blocks into xy order for column assignment
-  blocks = (TextBlock **)gmalloc(nBlocks * sizeof(TextBlock *));
+  blocks = (TextBlock **)gmallocn(nBlocks, sizeof(TextBlock *));
   for (blk = blkList, i = 0; blk; blk = blk->next, ++i) {
     blocks[i] = blk;
   }
@@ -2498,7 +2498,7 @@
   // build the flows
   //~ this needs to be adjusted for writing mode (vertical text)
   //~ this also needs to account for right-to-left column ordering
-  blkArray = (TextBlock **)gmalloc(nBlocks * sizeof(TextBlock *));
+  blkArray = (TextBlock **)gmallocn(nBlocks, sizeof(TextBlock *));
   memcpy(blkArray, blocks, nBlocks * sizeof(TextBlock *));
   flows = lastFlow = NULL;
   firstBlkIdx = 0;
@@ -2812,7 +2812,7 @@
 
   // collect the line fragments that are in the rectangle
   fragsSize = 256;
-  frags = (TextLineFrag *)gmalloc(fragsSize * sizeof(TextLineFrag));
+  frags = (TextLineFrag *)gmallocn(fragsSize, sizeof(TextLineFrag));
   nFrags = 0;
   lastRot = -1;
   oneRot = gTrue;
@@ -2914,7 +2914,7 @@
 	    if (nFrags == fragsSize) {
 	      fragsSize *= 2;
 	      frags = (TextLineFrag *)
-		          grealloc(frags, fragsSize * sizeof(TextLineFrag));
+		          greallocn(frags, fragsSize, sizeof(TextLineFrag));
 	    }
 	    frags[nFrags].init(line, idx0, idx1 - idx0 + 1);
 	    ++nFrags;
@@ -3706,15 +3706,15 @@
 
     // collect the line fragments for the page and sort them
     fragsSize = 256;
-    frags = (TextLineFrag *)gmalloc(fragsSize * sizeof(TextLineFrag));
+    frags = (TextLineFrag *)gmallocn(fragsSize, sizeof(TextLineFrag));
     nFrags = 0;
     for (i = 0; i < nBlocks; ++i) {
       blk = blocks[i];
       for (line = blk->lines; line; line = line->next) {
 	if (nFrags == fragsSize) {
 	  fragsSize *= 2;
-	  frags = (TextLineFrag *)grealloc(frags,
-					   fragsSize * sizeof(TextLineFrag));
+	  frags = (TextLineFrag *)greallocn(frags,
+					    fragsSize, sizeof(TextLineFrag));
 	}
 	frags[nFrags].init(line, 0, line->len);
 	frags[nFrags].computeCoords(gTrue);

Index: XRef.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/XRef.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- XRef.cc	5 Jul 2005 12:15:04 -0000	1.3
+++ XRef.cc	27 Aug 2005 08:43:43 -0000	1.4
@@ -1,4 +1,4 @@
-//========================================================================
+ //========================================================================
 //
 // XRef.cc
 //
@@ -121,8 +121,8 @@
   }
  
   objs = new Object[nObjects];
-  objNums = (int *)gmalloc(nObjects * sizeof(int));
-  offsets = (int *)gmalloc(nObjects * sizeof(int));
+  objNums = (int *)gmallocn(nObjects, sizeof(int));
+  offsets = (int *)gmallocn(nObjects, sizeof(int));
 
   // parse the header: object numbers and offsets
   objStr.streamReset();
@@ -403,7 +403,7 @@
         goto err1;
       }
  
-      entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
+      entries = (XRefEntry *)greallocn(entries, newSize, sizeof(XRefEntry));
       for (i = size; i < newSize; ++i) {
 	entries[i].offset = 0xffffffff;
 	entries[i].type = xrefEntryFree;
@@ -512,7 +512,7 @@
       error(-1, "Invalid 'size' parameter.");
       return gFalse;
     }
-    entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
+    entries = (XRefEntry *)greallocn(entries, newSize, sizeof(XRefEntry));
     for (i = size; i < newSize; ++i) {
       entries[i].offset = 0xffffffff;
       entries[i].type = xrefEntryFree;
@@ -606,7 +606,7 @@
       error(-1, "Invalid 'size' inside xref table.");
       return gFalse;
     }
-    entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
+    entries = (XRefEntry *)greallocn(entries, newSize, sizeof(XRefEntry));
     for (i = size; i < newSize; ++i) {
       entries[i].offset = 0xffffffff;
       entries[i].type = xrefEntryFree;
@@ -746,7 +746,7 @@
                     return gFalse;
                   }
 		  entries = (XRefEntry *)
-		      grealloc(entries, newSize * sizeof(XRefEntry));
+		      greallocn(entries, newSize, sizeof(XRefEntry));
 		  for (i = size; i < newSize; ++i) {
 		    entries[i].offset = 0xffffffff;
 		    entries[i].type = xrefEntryFree;
@@ -772,8 +772,8 @@
           error(-1, "Invalid 'endstream' parameter.");
           return gFalse;
         }
-	streamEnds = (Guint *)grealloc(streamEnds,
-				       streamEndsSize * sizeof(int));
+	streamEnds = (Guint *)greallocn(streamEnds,
+					streamEndsSize, sizeof(int));
       }
       streamEnds[streamEndsLen++] = pos;
     }



More information about the poppler mailing list