77 *
88 *
99 * 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 $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
1414
1515#ifndef FRONTEND
1616#include "postgres.h"
17- #define malloc (l ) palloc(l)
18- #define free (p ) pfree(p)
19- #define strdup (p ) pstrdup(p)
2017#else
2118#include "postgres_fe.h"
2219#endif
2320
2421#include <grp.h>
2522#include <pwd.h>
2623#include <sys/stat.h>
24+ #include <sys/wait.h>
2725#include <unistd.h>
2826
29- #include <sys/wait.h>
27+ #include "miscadmin.h"
3028
31- #define _ (x ) gettext((x) )
29+ #define _ (x ) gettext(x )
3230
33- #include "miscadmin.h"
31+ #ifdef FRONTEND
32+ #undef pstrdup
33+ #define pstrdup (p ) strdup(p)
34+ #define pfree (p ) free(p)
35+ #endif
3436
3537/* $PATH (or %PATH%) path separator */
3638#ifdef WIN32
5860#define log_error (str , param ) fprintf(stderr, (str), (param))
5961#endif
6062
63+
6164static void win32_make_absolute (char * path );
6265
66+
6367/*
6468 * validate_exec -- validate "path" as an executable file
6569 *
@@ -243,7 +247,7 @@ find_my_exec(const char *argv0, char *retpath)
243247 */
244248 if ((p = getenv ("PATH" )) && * p )
245249 {
246- path = strdup (p ); /* make a modifiable copy */
250+ path = pstrdup (p ); /* make a modifiable copy */
247251 for (startp = path , endp = strchr (path , PATHSEP );
248252 startp && * startp ;
249253 startp = endp + 1 , endp = strchr (startp , PATHSEP ))
@@ -263,19 +267,19 @@ find_my_exec(const char *argv0, char *retpath)
263267 {
264268 case 0 : /* found ok */
265269 win32_make_absolute (retpath );
266- free (path );
270+ pfree (path );
267271 return 0 ;
268272 case -1 : /* wasn't even a candidate, keep looking */
269273 break ;
270274 case -2 : /* found but disqualified */
271275 log_error ("could not read binary \"%s\"" , retpath );
272- free (path );
276+ pfree (path );
273277 return -1 ;
274278 }
275279 if (!endp ) /* last one */
276280 break ;
277281 }
278- free (path );
282+ pfree (path );
279283 }
280284
281285 log_error ("could not find a \"%s\" to execute" , argv0 );
@@ -296,8 +300,9 @@ find_my_exec(const char *argv0, char *retpath)
296300 * Find our binary directory, then make sure the "target" executable
297301 * is the proper version.
298302 */
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 )
301306{
302307 char cmd [MAXPGPATH ];
303308 char line [100 ];
@@ -380,8 +385,6 @@ pclose_check(FILE *stream)
380385/*
381386 * Windows doesn't like relative paths to executables (other things work fine)
382387 * so we call its builtin function to expand them. Elsewhere this is a NOOP
383- *
384- * Returns malloc'ed memory.
385388 */
386389static void
387390win32_make_absolute (char * path )
@@ -391,14 +394,11 @@ win32_make_absolute(char *path)
391394
392395 if (_fullpath (abspath , path , MAXPGPATH ) == NULL )
393396 {
394- log_error ("Win32 path expansion failed: %s" , strerror (errno ));
397+ log_error ("Win32 path expansion failed: %s" , strerror (errno ));
395398 StrNCpy (abspath , path , MAXPGPATH );
396399 }
397400 canonicalize_path (abspath );
398401
399402 StrNCpy (path , abspath , MAXPGPATH );
400403#endif
401- return ;
402404}
403-
404-
0 commit comments