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 */
244248if ((p = getenv ("PATH" ))&& * p )
245249{
246- path = strdup (p );/* make a modifiable copy */
250+ path = pstrdup (p );/* make a modifiable copy */
247251for (startp = path ,endp = strchr (path ,PATHSEP );
248252startp && * startp ;
249253startp = endp + 1 ,endp = strchr (startp ,PATHSEP ))
@@ -263,19 +267,19 @@ find_my_exec(const char *argv0, char *retpath)
263267{
264268case 0 :/* found ok */
265269win32_make_absolute (retpath );
266- free (path );
270+ pfree (path );
267271return 0 ;
268272case -1 :/* wasn't even a candidate, keep looking */
269273break ;
270274case -2 :/* found but disqualified */
271275log_error ("could not read binary \"%s\"" ,retpath );
272- free (path );
276+ pfree (path );
273277return -1 ;
274278}
275279if (!endp )/* last one */
276280break ;
277281}
278- free (path );
282+ pfree (path );
279283}
280284
281285log_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{
302307char cmd [MAXPGPATH ];
303308char 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
392395if (_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 ));
395398StrNCpy (abspath ,path ,MAXPGPATH );
396399}
397400canonicalize_path (abspath );
398401
399402StrNCpy (path ,abspath ,MAXPGPATH );
400403#endif
401- return ;
402404}
403-
404-