Changeset 9990
- Timestamp:
- Nov 14, 2006, 3:34:42 PM (20 years ago)
- Location:
- trunk/psLib/src/db
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r9985 r9990 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.11 0$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-11-15 0 0:54:22 $14 * @version $Revision: 1.111 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-11-15 01:34:42 $ 16 16 * 17 17 * Copyright (C) 2005-2006 Joshua Hoblitt, University of Hawaii … … 68 68 static psHash *mysqlToSqlLookupTable = NULL; 69 69 static psHash *pTypeToMysqlLookupTable = NULL; 70 71 // free func 72 static void psDBFree(psDB *dbh); 70 73 71 74 // database utility functions … … 120 123 /*****************************************************************************/ 121 124 122 psDB *psDB Init(const char *host,123 const char *user,124 const char *passwd,125 const char *dbname,126 unsigned int port)125 psDB *psDBAlloc(const char *host, 126 const char *user, 127 const char *passwd, 128 const char *dbname, 129 unsigned int port) 127 130 { 128 131 MYSQL *mysql; … … 180 183 } 181 184 185 // don't set the deallocator func until after we've setup the lookup tables 186 // so an alloc error doesn't try to free potentionally uncreated tables 187 psMemSetDeallocator(dbh, (psFreeFunc) psDBFree); 188 182 189 psTrace("psLib.db", PS_LOG_INFO, "connected to database %s", dbname); 183 190 … … 185 192 } 186 193 187 void psDBCleanup(psDB *dbh)194 static void psDBFree(psDB *dbh) 188 195 { 189 196 // quietly handle NULLs … … 194 201 // Attempt to close specified database connection 195 202 mysql_close(dbh->mysql); 196 psFree(dbh);197 203 198 204 // ASC WARNING NOTE: the psDBSQLToPTypeTableCleanup cleanup routine -
trunk/psLib/src/db/psDB.h
r9544 r9990 10 10 * @author Joshua Hoblitt 11 11 * 12 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-1 0-13 22:26:14$12 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-11-15 01:34:42 $ 14 14 * 15 15 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 40 40 /** Opens a new database connection 41 41 * 42 * @return psDB*: A new psDB object if the database connection is successful or NULL on 43 * failure. 44 */ 42 * @return psDB*: A new psDB object if the database connection is 43 * successful or NULL on failure. 44 */ 45 psDB *psDBAlloc( 46 const char *host, ///< Database server hostname 47 const char *user, ///< Database username 48 const char *passwd, ///< Database password 49 const char *dbname, ///< Database namespace 50 unsigned int port ///< Database port number 51 ); 52 53 /** Opens a new database connection 54 * 55 * This function is deprecated favor of psDBAlloc() 56 * 57 * @return psDB*: A new psDB object if the database connection is 58 * successful or NULL on failure. 59 */ 60 #ifdef DOXYGEN 45 61 psDB *psDBInit( 46 62 const char *host, ///< Database server hostname … … 50 66 unsigned int port ///< Database port number 51 67 ); 52 53 /** Closes a database connection */ 68 #else // DOXYGEN 69 #define psDBInit(host, user, passwd, dbname, port) \ 70 psDBAlloc(host, user, passwd, dbname, port) 71 #endif 72 73 #ifdef DOXYGEN 74 /** Closes a database connection 75 * 76 * This function is deprecated favor of psFree() 77 */ 54 78 void psDBCleanup( 55 79 psDB *dbh ///< Database handle 56 80 ); 81 #else // DOXYGEN 82 #define psDBCleanup(dbh) \ 83 psFree(dbh) 84 #endif 57 85 58 86 /** Creates a new database namespace
Note:
See TracChangeset
for help on using the changeset viewer.
