diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-24 19:28:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-24 19:28:25 +0300 |
commit | 612b060e8a5d9fed1e135c7b5a8108f4d8910374 (patch) | |
tree | 9f856f6a5f0ec3ef4e3e7a4aacaa37f6ff1f21de /src/debug | |
parent | 4ffba39b1411b230d6f79f44eadacfdbf3c85d40 (diff) | |
download | plus-612b060e8a5d9fed1e135c7b5a8108f4d8910374.tar.gz plus-612b060e8a5d9fed1e135c7b5a8108f4d8910374.tar.bz2 plus-612b060e8a5d9fed1e135c7b5a8108f4d8910374.tar.xz plus-612b060e8a5d9fed1e135c7b5a8108f4d8910374.zip |
Fix code style.
Diffstat (limited to 'src/debug')
-rw-r--r-- | src/debug/debug_new.cpp | 32 | ||||
-rw-r--r-- | src/debug/debug_new.h | 8 |
2 files changed, 24 insertions, 16 deletions
diff --git a/src/debug/debug_new.cpp b/src/debug/debug_new.cpp index 73b56bc7e..de0154a94 100644 --- a/src/debug/debug_new.cpp +++ b/src/debug/debug_new.cpp @@ -234,7 +234,8 @@ const int ALIGNED_LIST_ITEM_SIZE = align(sizeof(new_ptr_list_t)); /** * List of all new'd pointers. */ -static new_ptr_list_t new_ptr_list = { +static new_ptr_list_t new_ptr_list = +{ &new_ptr_list, &new_ptr_list, 0, @@ -340,9 +341,8 @@ static bool print_position_from_addr(const void* addr) strcpy(cmd + sizeof addr2line_cmd - 1, new_progname); size_t len = strlen(cmd); #if defined(__CYGWIN__) || defined(_WIN32) - if (len <= 4 - || (strcmp(cmd + len - 4, ".exe") != 0 && - strcmp(cmd + len - 4, ".EXE") != 0)) + if (len <= 4 || (strcmp(cmd + len - 4, ".exe") != 0 + && strcmp(cmd + len - 4, ".EXE") != 0)) { strcpy(cmd + len, ".exe"); len += 4; @@ -434,10 +434,12 @@ static void print_position(const void* ptr, int line) static bool check_tail(new_ptr_list_t* ptr) { const unsigned char* const pointer = (unsigned char*)ptr + - ALIGNED_LIST_ITEM_SIZE + ptr->size; + ALIGNED_LIST_ITEM_SIZE + ptr->size; for (int i = 0; i < _DEBUG_NEW_TAILCHECK; ++i) + { if (pointer[i] != _DEBUG_NEW_TAILCHECK_CHAR) return false; + } return true; } #endif @@ -478,10 +480,14 @@ static void* alloc_mem(size_t size, const char* file, int line, bool is_array) ptr->file = file; #else if (line) + { strncpy(ptr->file, file, _DEBUG_NEW_FILENAME_LEN - 1) [_DEBUG_NEW_FILENAME_LEN - 1] = '\0'; + } else + { ptr->addr = (void*)file; + } #endif ptr->line = line; ptr->is_array = is_array; @@ -528,7 +534,7 @@ static void free_pointer(void* pointer, void* addr, bool is_array) if (pointer == NULL) return; new_ptr_list_t* ptr = - (new_ptr_list_t*)((char*)pointer - ALIGNED_LIST_ITEM_SIZE); + (new_ptr_list_t*)((char*)pointer - ALIGNED_LIST_ITEM_SIZE); if (ptr->magic != MAGIC) { { @@ -651,16 +657,18 @@ int check_mem_corruption() fast_mutex_autolock lock_output(new_output_lock); fprintf(new_output_fp, "*** Checking for memory corruption: START\n"); for (new_ptr_list_t* ptr = new_ptr_list.next; - ptr != &new_ptr_list; - ptr = ptr->next) + ptr != &new_ptr_list; + ptr = ptr->next) { const char* const pointer = (char*)ptr + ALIGNED_LIST_ITEM_SIZE; if (ptr->magic == MAGIC #if _DEBUG_NEW_TAILCHECK - && check_tail(ptr) + && check_tail(ptr) #endif - ) + ) + { continue; + } #if _DEBUG_NEW_TAILCHECK if (ptr->magic != MAGIC) { @@ -684,7 +692,7 @@ int check_mem_corruption() else print_position(ptr->addr, ptr->line); fprintf(new_output_fp, ")\n"); - ++corrupt_cnt; + ++ corrupt_cnt; } fprintf(new_output_fp, "*** Checking for memory corruption: %d FOUND\n", corrupt_cnt); @@ -696,7 +704,7 @@ void __debug_new_recorder::_M_process(void* pointer) if (pointer == NULL) return; new_ptr_list_t* ptr = - (new_ptr_list_t*)((char*)pointer - ALIGNED_LIST_ITEM_SIZE); + (new_ptr_list_t*)((char*)pointer - ALIGNED_LIST_ITEM_SIZE); if (ptr->magic != MAGIC || ptr->line != 0) { fast_mutex_autolock lock(new_output_lock); diff --git a/src/debug/debug_new.h b/src/debug/debug_new.h index 5bcd06eb0..986092c2f 100644 --- a/src/debug/debug_new.h +++ b/src/debug/debug_new.h @@ -105,10 +105,10 @@ void operator delete[](void*) throw(); #endif /* Control variables */ -extern bool new_autocheck_flag; // default to true: call check_leaks() on exit -extern bool new_verbose_flag; // default to false: no verbose information -extern FILE* new_output_fp; // default to stderr: output to console -extern const char* new_progname;// default to NULL; should be assigned argv[0] +extern bool new_autocheck_flag; // default to true: call check_leaks() on exit +extern bool new_verbose_flag; // default to false: no verbose information +extern FILE* new_output_fp; // default to stderr: output to console +extern const char* new_progname; // default to NULL; should be assigned argv[0] /** * @def DEBUG_NEW |