|
10 | 10 | *Win32 (NT, Win2k, XP).replace() doesn't work on Win95/98/Me.
|
11 | 11 | *
|
12 | 12 | * IDENTIFICATION
|
13 |
| - * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.15 2004/08/0801:31:15 momjian Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.16 2004/08/0803:51:20 momjian Exp $ |
14 | 14 | *
|
15 | 15 | *-------------------------------------------------------------------------
|
16 | 16 | */
|
@@ -224,74 +224,34 @@ pgsymlink(const char *oldpath, const char *newpath)
|
224 | 224 | #endif
|
225 | 225 |
|
226 | 226 |
|
227 |
| -/* ---------------- |
228 |
| - *rmtree routines |
229 |
| - * ---------------- |
230 |
| - */ |
231 |
| - |
232 |
| - |
233 |
| -/* We undefined these above, so we redefine them */ |
| 227 | +/* We undefined this above, so we redefine it */ |
234 | 228 | #if defined(WIN32)|| defined(__CYGWIN__)
|
235 | 229 | #defineunlink(path)pgunlink(path)
|
236 | 230 | #endif
|
237 | 231 |
|
238 |
| -#ifdefFRONTEND |
239 |
| - |
240 |
| -staticvoid* |
241 |
| -xmalloc(size_tsize) |
242 |
| -{ |
243 |
| -void*result; |
244 |
| - |
245 |
| -result=malloc(size); |
246 |
| -if (!result) |
247 |
| - { |
248 |
| -fprintf(stderr,_("out of memory\n")); |
249 |
| -exit(1); |
250 |
| - } |
251 |
| -returnresult; |
252 |
| -} |
253 |
| - |
254 |
| -staticchar* |
255 |
| -xstrdup(constchar*s) |
256 |
| -{ |
257 |
| -char*result; |
258 |
| - |
259 |
| -result=strdup(s); |
260 |
| -if (!result) |
261 |
| - { |
262 |
| -fprintf(stderr,_("out of memory\n")); |
263 |
| -exit(1); |
264 |
| - } |
265 |
| -returnresult; |
266 |
| -} |
267 |
| - |
268 |
| -#definexfree(n) free(n) |
269 |
| - |
270 |
| -#else |
271 |
| - |
272 |
| -/* on the backend, use palloc and friends */ |
273 |
| - |
274 |
| -#definexmalloc(n)palloc(n) |
275 |
| -#definexstrdup(n)pstrdup(n) |
276 |
| -#definexfree(n)pfree(n) |
277 |
| - |
278 |
| -#endif |
279 |
| - |
280 | 232 | /*
|
281 |
| - * deallocate memory used for filenames |
| 233 | + *rmt_cleanup |
| 234 | + * |
| 235 | + *deallocate memory used for filenames |
282 | 236 | */
|
283 |
| - |
284 | 237 | staticvoid
|
285 | 238 | rmt_cleanup(char**filenames)
|
286 | 239 | {
|
287 | 240 | char**fn;
|
288 | 241 |
|
289 | 242 | for (fn=filenames;*fn;fn++)
|
290 |
| -xfree(*fn); |
| 243 | +#ifdefFRONTEND |
| 244 | +free(*fn); |
| 245 | + |
| 246 | +free(filenames); |
| 247 | +#else |
| 248 | +pfree(*fn); |
291 | 249 |
|
292 |
| -xfree(filenames); |
| 250 | +pfree(filenames); |
| 251 | +#endif |
293 | 252 | }
|
294 | 253 |
|
| 254 | + |
295 | 255 | /*
|
296 | 256 | *rmtree
|
297 | 257 | *
|
@@ -329,13 +289,30 @@ rmtree(char *path, bool rmtopdir)
|
329 | 289 |
|
330 | 290 | rewinddir(dir);
|
331 | 291 |
|
332 |
| -filenames=xmalloc((numnames+2)*sizeof(char*)); |
| 292 | +#ifdefFRONTEND |
| 293 | +if ((filenames=malloc((numnames+2)*sizeof(char*)))==NULL) |
| 294 | +{ |
| 295 | +fprintf(stderr,_("out of memory\n")); |
| 296 | +exit(1); |
| 297 | +} |
| 298 | +#else |
| 299 | +filenames=palloc((numnames+2)*sizeof(char*)); |
| 300 | +#endif |
| 301 | + |
333 | 302 | numnames=0;
|
334 | 303 |
|
335 | 304 | while ((file=readdir(dir))!=NULL)
|
336 | 305 | {
|
337 | 306 | if (strcmp(file->d_name,".")!=0&&strcmp(file->d_name,"..")!=0)
|
338 |
| -filenames[numnames++]=xstrdup(file->d_name); |
| 307 | +#ifdefFRONTEND |
| 308 | +if ((filenames[numnames++]=strdup(file->d_name))==NULL) |
| 309 | + { |
| 310 | +fprintf(stderr,_("out of memory\n")); |
| 311 | +exit(1); |
| 312 | +} |
| 313 | +#else |
| 314 | +filenames[numnames++]=pstrdup(file->d_name); |
| 315 | +#endif |
339 | 316 | }
|
340 | 317 |
|
341 | 318 | filenames[numnames]=NULL;
|
|