Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/interrogatedb/config_interrogatedb.cxx

Go to the documentation of this file.
00001 // Filename: config_interrogatedb.cxx
00002 // Created by:  drose (01Aug00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "config_interrogatedb.h"
00020 #include "interrogate_request.h"
00021 
00022 #include <dconfig.h>
00023 
00024 #if defined(WIN32_VC) && defined(_DEBUG)
00025 // _DEBUG assumes you are linking to msvcrt70d.dll, not msvcrt70.dll
00026 #define USE_WIN32_DBGHEAP
00027 #include <crtdbg.h>
00028 #endif
00029 
00030 Configure(config_interrogatedb);
00031 NotifyCategoryDef(interrogatedb, "");
00032 
00033 ConfigureFn(config_interrogatedb) {
00034   //  interrogate_request_library("types");
00035 
00036 #ifdef USE_WIN32_DBGHEAP
00037   string use_win32_dbgheap_str = config_interrogatedb.GetString("use-win32-dbgheap", "");
00038   bool win32_report_leaks = config_interrogatedb.GetBool("win32-report-leaks", false);
00039 
00040   int dbg_flags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
00041 
00042   if (use_win32_dbgheap_str == "full") {
00043     // "full" means check the heap after *every* alloc/dealloc.
00044     // Expensive.
00045     dbg_flags |= (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF |
00046                   _CRTDBG_CHECK_CRT_DF);
00047 
00048   } else {
00049     // Otherwise, it's a bool flag.  true means check the heap
00050     // normally, false means don't do any debug checking.
00051     bool use_win32_dbgheap_bool = config_interrogatedb.GetBool("use-win32-dbgheap", false);
00052 
00053     if (!use_win32_dbgheap_bool) {
00054       // deflt disable complete heap verify every 1024 allocations (VC7 deflt).
00055       // With vc7 stl small-string-optimization causing more allocs, 
00056       // this can cause order-of-magnitude slowdowns in dbg builds
00057       dbg_flags = 0;
00058     }
00059   }
00060 
00061   if (win32_report_leaks) {
00062     // Report memory still allocated at program termination.  Not sure
00063     // how useful this is, as many things get allocated once and never
00064     // freed, but they aren't really leaks.
00065     dbg_flags |= _CRTDBG_LEAK_CHECK_DF;
00066   }
00067 
00068   _CrtSetDbgFlag(dbg_flags);
00069 #endif
00070 }
00071 
00072 const DSearchPath &
00073 get_interrogatedb_path() {
00074   static DSearchPath *interrogatedb_path = NULL;
00075   if (interrogatedb_path == (DSearchPath *)NULL) {
00076     interrogatedb_path = new DSearchPath(".");
00077     interrogatedb_path->append_path
00078       (config_interrogatedb.GetString("ETC_PATH", "."));
00079   }
00080   return *interrogatedb_path;
00081 }
00082 

Generated on Thu May 1 22:13:04 2003 for DTool by doxygen1.3