ManaPlus
Public Member Functions | Static Private Attributes
debug_new_counter Class Reference

#include <debug_new.h>

Public Member Functions

 debug_new_counter ()
 
 ~debug_new_counter ()
 

Static Private Attributes

static int _S_count = 0
 

Detailed Description

Counter class for on-exit leakage check.

This technique is learnt from The C++ Programming Language by Bjarne Stroustup.

Definition at line 195 of file debug_new.h.

Constructor & Destructor Documentation

◆ debug_new_counter()

debug_new_counter::debug_new_counter ( )

Constructor to increment the count.

Definition at line 962 of file debug_new.cpp.

963 {
964  ++_S_count;
965 }
static int _S_count
Definition: debug_new.h:197

References _S_count.

◆ ~debug_new_counter()

debug_new_counter::~debug_new_counter ( )

Destructor to decrement the count. When the count is zero, nvwa::check_leaks will be called.

Definition at line 971 of file debug_new.cpp.

972 {
973  if (--_S_count == 0 && new_autocheck_flag)
974  if (check_leaks())
975  {
976  new_verbose_flag = true;
977 #if defined(__GNUC__) && __GNUC__ == 3
978  if (!getenv("GLIBCPP_FORCE_NEW") && !getenv("GLIBCXX_FORCE_NEW"))
979  fprintf(new_output_fp,
980 "*** WARNING: GCC 3 is detected, please make sure the environment\n"
981 " variable GLIBCPP_FORCE_NEW (GCC 3.2 and 3.3) or GLIBCXX_FORCE_NEW\n"
982 " (GCC 3.4) is defined. Check the README file for details.\n");
983 #endif
984  }
985 }
bool new_autocheck_flag
Definition: debug_new.cpp:333
bool new_verbose_flag
Definition: debug_new.cpp:338
int check_leaks()
Definition: debug_new.cpp:769
FILE * new_output_fp
Definition: debug_new.cpp:345

References _S_count, check_leaks(), new_autocheck_flag, new_output_fp, and new_verbose_flag.

Field Documentation

◆ _S_count

int debug_new_counter::_S_count = 0
staticprivate

Count of source files that use debug_new.

Definition at line 197 of file debug_new.h.

Referenced by debug_new_counter(), and ~debug_new_counter().


The documentation for this class was generated from the following files: