7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $PostgreSQL: pgsql/src/port/exec.c,v 1.12 2004/05/20 15:38:11 momjian Exp $
10
+ * $PostgreSQL: pgsql/src/port/exec.c,v 1.13 2004/05/21 16:06:23 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
14
14
15
15
#ifndef FRONTEND
16
16
#include "postgres.h"
17
- #define malloc (l ) palloc(l)
18
- #define free (p ) pfree(p)
19
- #define strdup (p ) pstrdup(p)
20
17
#else
21
18
#include "postgres_fe.h"
22
19
#endif
23
20
24
21
#include <grp.h>
25
22
#include <pwd.h>
26
23
#include <sys/stat.h>
24
+ #include <sys/wait.h>
27
25
#include <unistd.h>
28
26
29
- #include <sys/wait.h>
27
+ #include "miscadmin.h"
30
28
31
- #define _ (x ) gettext((x) )
29
+ #define _ (x ) gettext(x )
32
30
33
- #include "miscadmin.h"
31
+ #ifdef FRONTEND
32
+ #undef pstrdup
33
+ #define pstrdup (p ) strdup(p)
34
+ #define pfree (p ) free(p)
35
+ #endif
34
36
35
37
/* $PATH (or %PATH%) path separator */
36
38
#ifdef WIN32
58
60
#define log_error (str , param ) fprintf(stderr, (str), (param))
59
61
#endif
60
62
63
+
61
64
static void win32_make_absolute (char * path );
62
65
66
+
63
67
/*
64
68
* validate_exec -- validate "path" as an executable file
65
69
*
@@ -243,7 +247,7 @@ find_my_exec(const char *argv0, char *retpath)
243
247
*/
244
248
if ((p = getenv ("PATH" )) && * p )
245
249
{
246
- path = strdup (p ); /* make a modifiable copy */
250
+ path = pstrdup (p ); /* make a modifiable copy */
247
251
for (startp = path , endp = strchr (path , PATHSEP );
248
252
startp && * startp ;
249
253
startp = endp + 1 , endp = strchr (startp , PATHSEP ))
@@ -263,19 +267,19 @@ find_my_exec(const char *argv0, char *retpath)
263
267
{
264
268
case 0 : /* found ok */
265
269
win32_make_absolute (retpath );
266
- free (path );
270
+ pfree (path );
267
271
return 0 ;
268
272
case -1 : /* wasn't even a candidate, keep looking */
269
273
break ;
270
274
case -2 : /* found but disqualified */
271
275
log_error ("could not read binary \"%s\"" , retpath );
272
- free (path );
276
+ pfree (path );
273
277
return -1 ;
274
278
}
275
279
if (!endp ) /* last one */
276
280
break ;
277
281
}
278
- free (path );
282
+ pfree (path );
279
283
}
280
284
281
285
log_error ("could not find a \"%s\" to execute" , argv0 );
@@ -296,8 +300,9 @@ find_my_exec(const char *argv0, char *retpath)
296
300
* Find our binary directory, then make sure the "target" executable
297
301
* is the proper version.
298
302
*/
299
- int find_other_exec (const char * argv0 , char const * target ,
300
- const char * versionstr , char * retpath )
303
+ int
304
+ find_other_exec (const char * argv0 , const char * target ,
305
+ const char * versionstr , char * retpath )
301
306
{
302
307
char cmd [MAXPGPATH ];
303
308
char line [100 ];
@@ -380,8 +385,6 @@ pclose_check(FILE *stream)
380
385
/*
381
386
* Windows doesn't like relative paths to executables (other things work fine)
382
387
* so we call its builtin function to expand them. Elsewhere this is a NOOP
383
- *
384
- * Returns malloc'ed memory.
385
388
*/
386
389
static void
387
390
win32_make_absolute (char * path )
@@ -391,14 +394,11 @@ win32_make_absolute(char *path)
391
394
392
395
if (_fullpath (abspath , path , MAXPGPATH ) == NULL )
393
396
{
394
- log_error ("Win32 path expansion failed: %s" , strerror (errno ));
397
+ log_error ("Win32 path expansion failed: %s" , strerror (errno ));
395
398
StrNCpy (abspath , path , MAXPGPATH );
396
399
}
397
400
canonicalize_path (abspath );
398
401
399
402
StrNCpy (path , abspath , MAXPGPATH );
400
403
#endif
401
- return ;
402
404
}
403
-
404
-
0 commit comments