summaryrefslogtreecommitdiff
path: root/textproc/icu/patches/patch-bb
blob: 6afdd72306cf4e266137dcc319c5c58dea40c98a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$NetBSD: patch-bb,v 1.1 2008/03/20 17:07:54 drochner Exp $

--- common/uvectr32.h.orig	2006-01-18 04:52:04.000000000 +0100
+++ common/uvectr32.h
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 1999-2006, International Business Machines
+*   Copyright (C) 1999-2008, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 */
@@ -61,6 +61,8 @@ private:
     int32_t   count;
 
     int32_t   capacity;
+    
+    int32_t   maxCapacity;   // Limit beyond which capacity is not permitted to grow.
 
     int32_t*  elements;
 
@@ -162,6 +164,14 @@ public:
     int32_t *getBuffer() const;
 
     /**
+     * Set the maximum allowed buffer capacity for this vector/stack.
+     * Default with no limit set is unlimited, go until malloc() fails.
+     * A Limit of zero means unlimited capacity.
+     * Units are vector elements (32 bits each), not bytes.
+     */
+    void setMaxCapacity(int32_t limit);
+
+    /**
      * ICU "poor man's RTTI", returns a UClassID for this class.
      */
     static UClassID U_EXPORT2 getStaticClassID();
@@ -221,7 +231,9 @@ inline void UVector32::addElement(int32_
 }
 
 inline int32_t *UVector32::reserveBlock(int32_t size, UErrorCode &status) {
-    ensureCapacity(count+size, status);
+    if (ensureCapacity(count+size, status) == FALSE) {
+        return NULL;
+    }
     int32_t  *rp = elements+count;
     count += size;
     return rp;