]> granicus.if.org Git - postgresql/commitdiff
Major code cleanup following the pg_password insertion...
authorMarc G. Fournier <scrappy@hub.org>
Tue, 9 Dec 1997 03:11:25 +0000 (03:11 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Tue, 9 Dec 1997 03:11:25 +0000 (03:11 +0000)
...malloc/free -> palloc/pfree
...fopen/fclose -> AllocateFile/FreeFile

12 files changed:
src/backend/commands/user.c
src/backend/libpq/auth.c
src/backend/libpq/crypt.c
src/backend/libpq/hba.c
src/backend/libpq/password.c
src/backend/libpq/portal.c
src/backend/libpq/portalbuf.c
src/backend/libpq/pqpacket.c
src/backend/parser/scan.c
src/backend/postmaster/postmaster.c
src/bin/initlocation/initlocation
src/include/catalog/pg_user.h

index b08872856d82cbc7389570179dacdfed53dbe9f8..8f71fec451aaf7f132de93db9f1a812b0a7950e3 100644 (file)
@@ -176,7 +176,6 @@ extern void AlterUser(AlterUserStmt *stmt) {
   bool             exists = false,
                    n,
                    inblock;
-  int              max_id = -1;
 
   if (!(inblock = IsTransactionBlock()))
     BeginTransactionBlock();
index e4f1753800a42c9927181a9dfd26580ef5402a74..8aa3efca9b31377bc816e1f45f5bf493d6fc7db0 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.19 1997/12/04 00:26:50 scrappy Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.20 1997/12/09 03:10:31 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -397,10 +397,10 @@ pg_krb5_recvauth(int sock,
                                username, kusername);
                fputs(PQerrormsg, stderr);
                pqdebug("%s", PQerrormsg);
-               free(kusername);
+               pfree(kusername);
                return (STATUS_ERROR);
        }
-       free(kusername);
+       pfree(kusername);
        return (STATUS_OK);
 }
 
index 4e4cb15f81b3886b46fbcb1d26e621d534da51c8..8c1769cc5058b7df86108f0611368742045b4676 100644 (file)
 #include <crypt.h>
 #endif
 
-#include <postgres.h>
-#include <libpq/crypt.h>
-#include <utils/nabstime.h>
+#include "postgres.h"
+#include "libpq/crypt.h"
+#include "utils/nabstime.h"
+#include "utils/palloc.h"
+#include "storage/fd.h"
 
 char* crypt_getpwdfilename() {
 
@@ -32,7 +34,7 @@ char* crypt_getpwdfilename() {
       elog(FATAL, "crypt.c: PGDATA is not defined");
       exit(-1);
     }
-    filename = (char*)malloc(strlen(env) + strlen(CRYPT_PWD_FILE) + 2);
+    filename = (char*)palloc(strlen(env) + strlen(CRYPT_PWD_FILE) + 2);
     sprintf(filename, "%s/%s", env, CRYPT_PWD_FILE);
   }
 
@@ -47,7 +49,7 @@ FILE* crypt_openpwdfile() {
   char*     filename;
 
   filename = crypt_getpwdfilename();
-  return (fopen(filename, "r"));
+  return (AllocateFile(filename, "r"));
 }
 
 /*-------------------------------------------------------------------------*/
@@ -66,7 +68,7 @@ void crypt_parsepwdfile(FILE* datafile, char** login, char** pwd, char** valdate
   /* store a copy of user login to return
    */
   count = strcspn(parse, "#");
-  *login = (char*)malloc(count + 1);
+  *login = (char*)palloc(count + 1);
   strncpy(*login, parse, count);
   (*login)[count] = '\0';
   parse += (count + 1);
@@ -79,7 +81,7 @@ void crypt_parsepwdfile(FILE* datafile, char** login, char** pwd, char** valdate
   /* store a copy of user password to return
    */
   count = strcspn(parse, "#");
-  *pwd = (char*)malloc(count + 1);
+  *pwd = (char*)palloc(count + 1);
   strncpy(*pwd, parse, count);
   (*pwd)[count] = '\0';
   parse += (count + 1);
@@ -87,7 +89,7 @@ void crypt_parsepwdfile(FILE* datafile, char** login, char** pwd, char** valdate
   /* store a copy of date login becomes invalid
    */
   count = strcspn(parse, "#");
-  *valdate = (char*)malloc(count + 1);
+  *valdate = (char*)palloc(count + 1);
   strncpy(*valdate, parse, count);
   (*valdate)[count] = '\0';
   parse += (count + 1);
@@ -112,15 +114,15 @@ void crypt_getloginfo(const char* user, char** passwd, char** valuntil) {
   while (!feof(datafile)) {
     crypt_parsepwdfile(datafile, &login, &pwd, &valdate);
     if (!strcmp(login, user)) {
-      free((void*)login);
+      pfree((void*)login);
       *passwd = pwd;
       *valuntil = valdate;
       fclose(datafile);
       return;
     }
-    free((void*)login);
-    free((void*)pwd);
-    free((void*)valdate);
+    pfree((void*)login);
+    pfree((void*)pwd);
+    pfree((void*)valdate);
   }
   fclose(datafile);
 }
@@ -135,13 +137,13 @@ MsgType crypt_salt(const char* user) {
   crypt_getloginfo(user, &passwd, &valuntil);
 
   if (passwd == NULL || *passwd == '\0') {
-    if (passwd) free((void*)passwd);
-    if (valuntil) free((void*)valuntil);
+    if (passwd) pfree((void*)passwd);
+    if (valuntil) pfree((void*)valuntil);
     return STARTUP_UNSALT_MSG;
   }
 
-  free((void*)passwd);
-  if (valuntil) free((void*)valuntil);
+  pfree((void*)passwd);
+  if (valuntil) pfree((void*)valuntil);
   return STARTUP_SALT_MSG;
 }
 
@@ -159,8 +161,8 @@ int crypt_verify(Port* port, const char* user, const char* pgpass) {
   crypt_getloginfo(user, &passwd, &valuntil);
 
   if (passwd == NULL || *passwd == '\0') {
-    if (passwd) free((void*)passwd);
-    if (valuntil) free((void*)valuntil);
+    if (passwd) pfree((void*)passwd);
+    if (valuntil) pfree((void*)valuntil);
     return STATUS_ERROR;
   }
 
@@ -179,8 +181,8 @@ int crypt_verify(Port* port, const char* user, const char* pgpass) {
       retval = STATUS_OK;
   }
 
-  free((void*)passwd);
-  if (valuntil) free((void*)valuntil);
+  pfree((void*)passwd);
+  if (valuntil) pfree((void*)valuntil);
   
   return retval;
 }
index 02bea1ad78a32c683770031299f2184d87dfc836..3390f38f9a6a666a453734eead5284cbd841ebf0 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.24 1997/11/10 05:15:52 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.25 1997/12/09 03:10:38 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -404,7 +404,7 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
 
 
        /* put together the full pathname to the old config file */
-       old_conf_file = (char *) malloc((strlen(DataDir) +
+       old_conf_file = (char *) palloc((strlen(DataDir) +
                                                          strlen(OLD_CONF_FILE) + 2) * sizeof(char));
        sprintf(old_conf_file, "%s/%s", DataDir, OLD_CONF_FILE);
 
@@ -427,7 +427,7 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
                                                                 * read */
 
                /* put together the full pathname to the config file */
-               conf_file = (char *) malloc((strlen(DataDir) +
+               conf_file = (char *) palloc((strlen(DataDir) +
                                                                  strlen(CONF_FILE) + 2) * sizeof(char));
                sprintf(conf_file, "%s/%s", DataDir, CONF_FILE);
 
@@ -452,9 +452,9 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
                                                                         usermap_name, find_password_entries);
                        FreeFile(file);
                }
-               free(conf_file);
+               pfree(conf_file);
        }
-       free(old_conf_file);
+       pfree(old_conf_file);
        return;
 }
 
@@ -799,7 +799,7 @@ verify_against_usermap(const char DataDir[],
                                                                 * read */
 
                /* put together the full pathname to the map file */
-               map_file = (char *) malloc((strlen(DataDir) +
+               map_file = (char *) palloc((strlen(DataDir) +
                                                                        strlen(MAP_FILE) + 2) * sizeof(char));
                sprintf(map_file, "%s/%s", DataDir, MAP_FILE);
 
@@ -826,7 +826,7 @@ verify_against_usermap(const char DataDir[],
                                                                                checks_out_p);
                        FreeFile(file);
                }
-               free(map_file);
+               pfree(map_file);
 
 
        }
index aaaf297911f2fcc3ecf1ca264ddb3de72d153e37..8f26597f6a463bc7412ea1c45686eda8cb1f208e 100644 (file)
@@ -56,7 +56,7 @@ verify_password(char *user, char *password, Port *port,
                return STATUS_ERROR;
        }
 
-       pw_file_fullname = (char *) malloc(strlen(DataDir) + strlen(pw_file_name) + 2);
+       pw_file_fullname = (char *) palloc(strlen(DataDir) + strlen(pw_file_name) + 2);
        strcpy(pw_file_fullname, DataDir);
        strcat(pw_file_fullname, "/");
        strcat(pw_file_fullname, pw_file_name);
index d397eb8c8faf4f03b6ac578cb2592bab95445703..14c11127bc52c8f1c88c9b0ebaebac6d50cba65e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.11 1997/11/10 05:15:54 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.12 1997/12/09 03:10:43 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -612,7 +612,7 @@ PQgetAttr(PortalBuffer *portal,
        if (tbp)
        {
                len = tbp->lengths[tuple_offset][field_number];
-               result = malloc(len + 1);
+               result = palloc(len + 1);
                memcpy(result,
                           tbp->values[tuple_offset][field_number],
                           len);
index 82956fe2329e9bcb7b2fbf53f3ce4e609671f614..7bdebc2b3486dacb3874f607dac66747900141cd 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.8 1997/10/25 01:09:23 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.9 1997/12/09 03:10:45 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -58,7 +58,7 @@
 PortalEntry **portals = (PortalEntry **) NULL;
 size_t         portals_array_size = 0;
 
-/* portals array memory is malloc'd instead of using MemoryContexts */
+/* portals array memory is palloc'd instead of using MemoryContexts */
 /* since it will be used by both front and backend programs*/
 /*     GlobalMemory portals_mmcxt = (GlobalMemory) NULL;  */
 
@@ -83,7 +83,7 @@ portals_realloc(size_t size)
                newp = (PortalEntry **) realloc(portals,
                                                         portals_array_size * sizeof(PortalEntry *));
        else
-               newp = (PortalEntry **) malloc(portals_array_size * sizeof(PortalEntry *));
+               newp = (PortalEntry **) palloc(portals_array_size * sizeof(PortalEntry *));
 
        if (newp)
                portals = newp;
index afc364b5c3e200359e023d1e2bf0254b956c6243..b62eb3ee3633c616de0a13ad53a35d8ce3a8174d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.11 1997/11/17 16:18:07 thomas Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.12 1997/12/09 03:10:51 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -253,7 +253,7 @@ StartupInfo2PacketBuf(StartupInfo* s)
   PacketBuf* res;
   char* tmp;
 
-  res = (PacketBuf*)malloc(sizeof(PacketBuf));
+  res = (PacketBuf*)palloc(sizeof(PacketBuf));
   res->len = htonl(sizeof(PacketBuf));
   res->data[0] = '\0';
 
@@ -285,7 +285,7 @@ PacketBuf2StartupInfo(PacketBuf* p)
   StartupInfo* res;
   char* tmp;
 
-  res = (StartupInfo*)malloc(sizeof(StartupInfo));
+  res = (StartupInfo*)palloc(sizeof(StartupInfo));
 
   res->database[0]='\0';
   res->user[0]='\0';
index 646dac830e21d32ffd1d4a44d8bc81e612a0aac8..344fcfe3633abdb18107e4f3c490dd0f408af7dd 100644 (file)
@@ -1,7 +1,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.4 1997/11/30 23:05:39 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.5 1997/12/09 03:11:00 scrappy Exp $
  */
 
 #define FLEX_SCANNER
@@ -539,7 +539,7 @@ char *yytext;
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.4 1997/11/30 23:05:39 thomas Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.5 1997/12/09 03:11:00 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1212,7 +1212,7 @@ YY_RULE_SETUP
                                        int i;
                                        ScanKeyword             *keyword;
 
-                                       for(i = strlen(yytext); i >= 0; i--)
+                                       for(i = 0; yytext[i]; i++)
                                                if (isupper(yytext[i]))
                                                        yytext[i] = tolower(yytext[i]);
 
index 7201d0a6d994429cd7545f63d8fe84c83d427597..2e62d10136235eea96a54b614a2c5a84804b29ee 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.64 1997/12/07 20:57:45 scrappy Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.65 1997/12/09 03:11:08 scrappy Exp $
  *
  * NOTES
  *
@@ -88,6 +88,7 @@
 #include "storage/proc.h"
 #include "utils/elog.h"
 #include "port-protos.h"               /* For gethostname() */
+#include "storage/fd.h"
 
 #if defined(DBX_VERSION)
 #define FORK() (0)
@@ -228,7 +229,7 @@ checkDataDir(const char *DataDir, bool *DataDirOK)
 
                sprintf(path, "%s%cbase%ctemplate1%cpg_class",
                                DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR);
-               fp = fopen(path, "r");
+               fp = AllocateFile(path, "r");
                if (fp == NULL)
                {
                        fprintf(stderr, "%s does not find the database system.  "
@@ -244,7 +245,7 @@ checkDataDir(const char *DataDir, bool *DataDirOK)
 
                        /* reason ValidatePgVersion failed.  NULL if didn't */
 
-                       fclose(fp);
+                       FreeFile(fp);
 
                        ValidatePgVersion(DataDir, &reason);
                        if (reason)
index a263b85eea432bdbaaf3832d137744bf70180d20..02dd79e7f71c336c57fec3856d666ec8b76c3e8d 100644 (file)
@@ -12,7 +12,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation,v 1.1 1997/11/07 06:21:38 thomas Exp $
+#    $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation,v 1.2 1997/12/09 03:11:16 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -35,11 +35,11 @@ do
        shift
 done
 
-if [ ! -z "$badparm" ]; then
+if [ -n "$badparm" ]; then
        echo "$CMDNAME: Unrecognized parameter '$badparm'"
 fi
 
-if [ ! -z "$usage" ]; then
+if [ -n "$usage" ]; then
        echo "Usage: $CMDNAME [-u SUPERUSER] DATADIR"
        exit 1
 fi
index 8e6bb2cd0ee1a825dee3d21344741d846b87ddd5..970ab7973f35bf035e6970f5bff181c85371d7a4 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_user.h,v 1.6 1997/12/04 00:27:54 scrappy Exp $
+ * $Id: pg_user.h,v 1.7 1997/12/09 03:11:25 scrappy Exp $
  *
  * NOTES
  *       the genbki.sh script reads this file and generates .bki
@@ -65,7 +65,7 @@ typedef FormData_pg_user *Form_pg_user;
  *             initial contents of pg_user
  * ----------------
  */
-DATA(insert OID = 0 ( postgres PGUID t t t t postgres 2116994400 ));
+DATA(insert OID = 0 ( postgres PGUID t t t t "" 2116994400 ));
 
 BKI_BEGIN
 #ifdef ALLOW_PG_GROUP