Codebase list shapelib / ea69579
Remove patch 0002 (Thread safety fixes), no longer needed Arto Jantunen 10 years ago
2 changed file(s) with 0 addition(s) and 182 deletion(s). Raw diff Collapse all Expand all
+0
-181
debian/patches/0002-Thread-safety-fixes.patch less more
0 From: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
1 Date: Fri, 8 Apr 2005 10:51:19 +0200
2 Subject: [PATCH] Thread safety fixes
3
4 ---
5 dbfopen.c | 60 +++++++++++++++++++++++++++++++++---------------------------
6 shapefil.h | 5 +++++
7 2 files changed, 38 insertions(+), 27 deletions(-)
8
9 diff --git a/dbfopen.c b/dbfopen.c
10 index 43b25ac..178ae18 100644
11 --- a/dbfopen.c
12 +++ b/dbfopen.c
13 @@ -197,8 +197,6 @@ static char rcsid[] =
14 # define TRUE 1
15 #endif
16
17 -static int nStringFieldLen = 0;
18 -static char * pszStringField = NULL;
19
20 /************************************************************************/
21 /* SfRealloc() */
22 @@ -431,6 +429,12 @@ DBFOpen( const char * pszFilename, const char * pszAccess )
23 psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1];
24 }
25
26 +/* -------------------------------------------------------------------- */
27 +/* Initialize our temporary input fields. */
28 +/* -------------------------------------------------------------------- */
29 + psDBF->nStringFieldLen = 0;
30 + psDBF->pszStringField = NULL;
31 +
32 return( psDBF );
33 }
34
35 @@ -489,14 +493,12 @@ DBFClose(DBFHandle psDBF)
36 free( psDBF->pszHeader );
37 free( psDBF->pszCurrentRecord );
38
39 - free( psDBF );
40 -
41 - if( pszStringField != NULL )
42 + if( psDBF->pszStringField != NULL )
43 {
44 - free( pszStringField );
45 - pszStringField = NULL;
46 - nStringFieldLen = 0;
47 + free( psDBF->pszStringField );
48 }
49 +
50 + free( psDBF );
51 }
52
53 /************************************************************************/
54 @@ -571,6 +573,12 @@ DBFCreate( const char * pszFilename )
55
56 psDBF->bNoHeader = TRUE;
57
58 +/* --------------------------------------------------------------------*/
59 +/* Initialize our temporary input fields.*/
60 +/* --------------------------------------------------------------------*/
61 + psDBF->nStringFieldLen = 0;
62 + psDBF->pszStringField = NULL;
63 +
64 return( psDBF );
65 }
66
67 @@ -691,7 +699,6 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
68 unsigned char *pabyRec;
69 void *pReturnField = NULL;
70
71 - static double dDoubleField;
72
73 /* -------------------------------------------------------------------- */
74 /* Verify selection. */
75 @@ -734,30 +741,31 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
76 /* -------------------------------------------------------------------- */
77 /* Ensure our field buffer is large enough to hold this buffer. */
78 /* -------------------------------------------------------------------- */
79 - if( psDBF->panFieldSize[iField]+1 > nStringFieldLen )
80 + if( psDBF->panFieldSize[iField]+1 > psDBF->nStringFieldLen )
81 {
82 - nStringFieldLen = psDBF->panFieldSize[iField]*2 + 10;
83 - pszStringField = (char *) SfRealloc(pszStringField,nStringFieldLen);
84 + psDBF->nStringFieldLen = psDBF->panFieldSize[iField]*2 + 10;
85 + psDBF->pszStringField = (char *) SfRealloc(psDBF->pszStringField,
86 + psDBF->nStringFieldLen);
87 }
88
89 /* -------------------------------------------------------------------- */
90 /* Extract the requested field. */
91 /* -------------------------------------------------------------------- */
92 - strncpy( pszStringField,
93 + strncpy( psDBF->pszStringField,
94 ((const char *) pabyRec) + psDBF->panFieldOffset[iField],
95 psDBF->panFieldSize[iField] );
96 - pszStringField[psDBF->panFieldSize[iField]] = '\0';
97 + psDBF->pszStringField[psDBF->panFieldSize[iField]] = '\0';
98
99 - pReturnField = pszStringField;
100 + pReturnField = psDBF->pszStringField;
101
102 /* -------------------------------------------------------------------- */
103 /* Decode the field. */
104 /* -------------------------------------------------------------------- */
105 if( chReqType == 'N' )
106 {
107 - dDoubleField = atof(pszStringField);
108 + psDBF->dDoubleField = atof(psDBF->pszStringField);
109
110 - pReturnField = &dDoubleField;
111 + pReturnField = &psDBF->dDoubleField;
112 }
113
114 /* -------------------------------------------------------------------- */
115 @@ -768,7 +776,7 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
116 {
117 char *pchSrc, *pchDst;
118
119 - pchDst = pchSrc = pszStringField;
120 + pchDst = pchSrc = psDBF->pszStringField;
121 while( *pchSrc == ' ' )
122 pchSrc++;
123
124 @@ -776,7 +784,7 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
125 *(pchDst++) = *(pchSrc++);
126 *pchDst = '\0';
127
128 - while( pchDst != pszStringField && *(--pchDst) == ' ' )
129 + while( pchDst != psDBF->pszStringField && *(--pchDst) == ' ' )
130 *pchDst = '\0';
131 }
132 #endif
133 @@ -1351,9 +1359,6 @@ DBFReadTuple(DBFHandle psDBF, int hEntity )
134 {
135 int nRecordOffset;
136 unsigned char *pabyRec;
137 - static char *pReturnTuple = NULL;
138 -
139 - static int nTupleLen = 0;
140
141 /* -------------------------------------------------------------------- */
142 /* Have we read the record? */
143 @@ -1375,14 +1380,15 @@ DBFReadTuple(DBFHandle psDBF, int hEntity )
144
145 pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
146
147 - if ( nTupleLen < psDBF->nRecordLength) {
148 - nTupleLen = psDBF->nRecordLength;
149 - pReturnTuple = (char *) SfRealloc(pReturnTuple, psDBF->nRecordLength);
150 + if ( psDBF->nStringFieldLen < psDBF->nRecordLength) {
151 + psDBF->nStringFieldLen = psDBF->nRecordLength;
152 + psDBF->pszStringField = (char *) SfRealloc(psDBF->pszStringField,
153 + psDBF->nRecordLength);
154 }
155
156 - memcpy ( pReturnTuple, pabyRec, psDBF->nRecordLength );
157 + memcpy ( psDBF->pszStringField, pabyRec, psDBF->nRecordLength );
158
159 - return( pReturnTuple );
160 + return( psDBF->pszStringField );
161 }
162
163 /************************************************************************/
164 diff --git a/shapefil.h b/shapefil.h
165 index 19ba921..0244ba1 100644
166 --- a/shapefil.h
167 +++ b/shapefil.h
168 @@ -401,6 +401,11 @@ typedef struct
169
170 int bNoHeader;
171 int bUpdated;
172 +
173 + int nStringFieldLen;
174 + char *pszStringField;
175 +
176 + double dDoubleField;
177 } DBFInfo;
178
179 typedef DBFInfo * DBFHandle;
180 --
00 0001-Add-manpages.patch
1 0002-Thread-safety-fixes.patch
21 0003-Properly-use-libtool.patch
32 0004-Dynamically-link-the-shp-binaries-to-libshp.patch
43 0005-Stop-setting-CFLAGS-in-the-Makefile.patch