21namespace layer1_foundations {
22namespace orbiter_kernel_system {
25static int registry_key_pair_compare_by_size(
void *K1v,
void *K2v);
26static int registry_key_pair_compare_by_type(
void *K1v,
void *K2v);
27static int registry_key_pair_compare_by_location(
void *K1v,
void *K2v);
34 int verbose_level = 0;
61 int f_v = (verbose_level >= 1);
64 cout <<
"mem_object_registry::init" << endl;
78 cout <<
"mem_object_registry::init trying to allocate "
85 cout <<
"mem_object_registry::init allocation successful" << endl;
90 cout <<
"mem_object_registry::init done" << endl;
97 int f_v = (verbose_level >= 1);
100 cout <<
"mem_object_registry::accumulate_and_ignore_duplicates" << endl;
108 int f_v = (verbose_level >= 1);
111 cout <<
"mem_object_registry::allocate" << endl;
118 cout <<
"mem_object_registry::allocate "
119 "trying to allocate "
126 cout <<
"mem_object_registry::allocate allocation successful" << endl;
131 cout <<
"mem_object_registry::allocate done" << endl;
138 int automatic_dump_interval,
const char *fname_mask,
141 int f_v = (verbose_level >= 1);
144 cout <<
"mem_object_registry::set_automatic_dump" << endl;
164 cout <<
"automatic memory dump " << a << endl;
195 cout <<
"memory registry:" << endl;
206 cout <<
"cur_time=" <<
cur_time << endl;
207 cout <<
"total allocation size in char=" << sz << endl;
208 cout <<
"table of all currently active memory allocations in increasing "
209 "order of the value of the pointer" << endl;
226 fp <<
"Line,Pointer,Timestamp,Type,N,Sizeof,"
227 "ExtraTypeInfo,File,LineInFile" << endl;
241 fp <<
"cur_time=" <<
cur_time << endl;
242 fp <<
"total allocation size in char=" << sz << endl;
248 const char *file,
int line)
256 cout <<
"mem_object_registry::allocate_int cur_time=" <<
cur_time <<
" int[n], "
257 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
273 cout <<
"mem_object_registry::free_int int[n], "
274 " file=" << file <<
" line=" << line << endl;
277 cout <<
"mem_object_registry::free_int "
278 "NULL pointer, ignoring" << endl;
279 cout <<
"p=" << p <<
" file=" << file
280 <<
" line=" << line << endl;
290 const char *file,
int line)
297 cout <<
"mem_object_registry::allocate_lint cur_time=" <<
cur_time <<
" int[n], "
298 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
314 cout <<
"mem_object_registry::free_lint int[n], "
315 " file=" << file <<
" line=" << line << endl;
318 cout <<
"mem_object_registry::free_lint "
319 "NULL pointer, ignoring" << endl;
320 cout <<
"p=" << p <<
" file=" << file
321 <<
" line=" << line << endl;
331 const char *file,
int line)
338 cout <<
"mem_object_registry::allocate_pint cur_time=" <<
cur_time <<
" pint[n], "
339 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
351 const char *file,
int line)
356 cout <<
"mem_object_registry::free_pint pint[n], "
357 " file=" << file <<
" line=" << line << endl;
360 cout <<
"mem_object_registry::free_pint "
361 "NULL pointer, ignoring" << endl;
362 cout <<
"p=" << p <<
" file=" << file
363 <<
" line=" << line << endl;
373 const char *file,
int line)
380 cout <<
"mem_object_registry::allocate_plint cur_time=" <<
cur_time <<
" plint[n], "
381 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
393 const char *file,
int line)
398 cout <<
"mem_object_registry::free_plint pint[n], "
399 " file=" << file <<
" line=" << line << endl;
402 cout <<
"mem_object_registry::free_plint "
403 "NULL pointer, ignoring" << endl;
404 cout <<
"p=" << p <<
" file=" << file
405 <<
" line=" << line << endl;
415 const char *file,
int line)
422 cout <<
"mem_object_registry::allocate_ppint cur_time=" <<
cur_time <<
" ppint[n], "
423 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
439 cout <<
"mem_object_registry::free_ppint ppint[n], "
440 " file=" << file <<
" line=" << line << endl;
443 cout <<
"mem_object_registry::free_ppint "
444 "NULL pointer, ignoring" << endl;
445 cout <<
"p=" << p <<
" file=" << file
446 <<
" line=" << line << endl;
456 const char *file,
int line)
463 cout <<
"mem_object_registry::allocate_ppint cur_time=" <<
cur_time <<
" pplint[n], "
464 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
480 cout <<
"mem_object_registry::free_pplint ppint[n], "
481 " file=" << file <<
" line=" << line << endl;
484 cout <<
"mem_object_registry::free_pplint "
485 "NULL pointer, ignoring" << endl;
486 cout <<
"p=" << p <<
" file=" << file
487 <<
" line=" << line << endl;
497 const char *file,
int line)
504 cout <<
"mem_object_registry::allocate_char cur_time=" <<
cur_time <<
" char[n], "
505 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << (
int *) p << endl;
521 cout <<
"mem_object_registry::free_char char[n], "
522 " file=" << file <<
" line=" << line << endl;
525 cout <<
"mem_object_registry::free_char "
526 "NULL pointer, ignoring" << endl;
527 cout <<
"p=" << p <<
" file=" << file
528 <<
" line=" << line << endl;
538 const char *file,
int line)
545 cout <<
"mem_object_registry::allocate_uchar cur_time=" <<
cur_time <<
" uchar[n], "
546 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << (
int *) p << endl;
558 const char *file,
int line)
563 cout <<
"mem_object_registry::free_uchar uchar[n], "
564 " file=" << file <<
" line=" << line << endl;
567 cout <<
"mem_object_registry::free_uchar "
568 "NULL pointer, ignoring" << endl;
569 cout <<
"p=" << p <<
" file=" << file
570 <<
" line=" << line << endl;
580 const char *file,
int line)
587 cout <<
"mem_object_registry::allocate_pchar cur_time=" <<
cur_time <<
" pchar[n], "
588 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << (
int *) p << endl;
600 const char *file,
int line)
605 cout <<
"mem_object_registry::free_pchar pchar[n], "
606 " file=" << file <<
" line=" << line << endl;
609 cout <<
"mem_object_registry::free_pchar "
610 "NULL pointer, ignoring" << endl;
611 cout <<
"p=" << p <<
" file=" << file
612 <<
" line=" << line << endl;
622 const char *file,
int line)
629 cout <<
"mem_object_registry::allocate_puchar cur_time=" <<
cur_time <<
" puchar[n], "
630 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << (
int *) p << endl;
642 const char *file,
int line)
647 cout <<
"mem_object_registry::free_puchar puchar[n], "
648 " file=" << file <<
" line=" << line << endl;
651 cout <<
"mem_object_registry::free_puchar "
652 "NULL pointer, ignoring" << endl;
653 cout <<
"p=" << p <<
" file=" << file
654 <<
" line=" << line << endl;
664 const char *file,
int line)
671 cout <<
"mem_object_registry::allocate_pvoid cur_time=" <<
cur_time <<
" pvoid[n], "
672 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
684 const char *file,
int line)
689 cout <<
"mem_object_registry::free_pvoid pvoid[n], "
690 " file=" << file <<
" line=" << line << endl;
693 cout <<
"mem_object_registry::free_pvoid "
694 "NULL pointer, ignoring" << endl;
695 cout <<
"p=" << p <<
" file=" << file
696 <<
" line=" << line << endl;
706 long int n, std::size_t size_of,
707 const char *extra_type_info,
const char *file,
int line)
712 cout <<
"mem_object_registry::allocate_OBJECTS cur_time=" <<
cur_time <<
" char[n * size_of], "
713 "n=" << n <<
" file=" << file <<
" line=" << line <<
" p=" << p << endl;
718 extra_type_info, file, line,
725 const char *file,
int line)
730 cout <<
"mem_object_registry::free_OBJECTS char[n * size_of], "
731 " file=" << file <<
" line=" << line << endl;
734 cout <<
"mem_object_registry::free_OBJECTS "
735 "NULL pointer, ignoring" << endl;
736 cout <<
"p=" << p <<
" file=" << file
737 <<
" line=" << line << endl;
747 const char *extra_type_info,
const char *file,
int line)
752 cout <<
"mem_object_registry::allocate_OBJECT cur_time=" <<
cur_time <<
" char[size_of], "
753 " file=" << file <<
" line=" << line <<
" p=" << p << endl;
758 extra_type_info, file, line,
765 const char *file,
int line)
770 cout <<
"mem_object_registry::free_OBJECT char[size_of], "
771 " file=" << file <<
" line=" << line << endl;
774 cout <<
"mem_object_registry::free_OBJECTS "
775 "NULL pointer, ignoring" << endl;
776 cout <<
"p=" << p <<
" file=" << file
777 <<
" line=" << line << endl;
835 cout <<
"mem_object_registry::insert_at reallocating table to "
844 delete [] old_entries;
854 int object_type,
long int object_n,
int object_size_of,
855 const char *extra_type_info,
856 const char *source_file,
int source_line,
859 int f_v = (verbose_level >= 1);
863 cout <<
"mem_object_registry::add_to_registry" << endl;
866 if (
search(pointer, idx)) {
871 cout <<
"mem_object_registry::add_to_registry pointer p is "
872 "already in the registry, something is wrong" << endl;
873 cout <<
"extra_type_info = " << extra_type_info << endl;
874 cout <<
"source_file = " << source_file << endl;
875 cout <<
"source_line = " << source_line << endl;
876 cout <<
"object_type = " << object_type << endl;
877 cout <<
"object_n = " << object_n << endl;
878 cout <<
"object_size_of = " << object_size_of << endl;
879 cout <<
"the previous object is:" << endl;
881 cout <<
"ignoring the problem" << endl;
901 cout <<
"mem_object_registry::add_to_registry done, there are "
908 int f_v = (verbose_level >= 1);
912 cout <<
"mem_object_registry::delete_from_registry" << endl;
920 if (!
search(pointer, idx)) {
921 cout <<
"mem_object_registry::delete_from_registry pointer is "
922 "not in registry, something is wrong; "
923 "ignoring, pointer = " << pointer << endl;
935 cout <<
"mem_object_registry::delete_from_registry done, there are "
941 int f_v = (verbose_level >= 1);
945 cout <<
"mem_object_registry::sort_by_size" << endl;
949 cout <<
"mem_object_registry::sort_by_size before Heapsort" << endl;
953 registry_key_pair_compare_by_size);
955 cout <<
"mem_object_registry::sort_by_size after Heapsort" << endl;
959 cout <<
"mem_object_registry::sort_by_size done" << endl;
967 int f_v = (verbose_level >= 1);
972 cout <<
"mem_object_registry::sort_by_location_and_get_frequency" << endl;
990 c = registry_key_pair_compare_by_location(
993 type_len[nb_types]++;
996 type_first[nb_types + 1] =
997 type_first[nb_types] + type_len[nb_types];
999 type_len[nb_types] = 1;
1003 cout <<
"we have " << nb_types
1004 <<
" different allocation locations:" << endl;
1011 perm =
new int[nb_types];
1012 perm_inv =
new int[nb_types];
1013 frequency =
new int[nb_types];
1018 perm, perm_inv,
FALSE );
1020 for (t = nb_types - 1; t >= 0; t--) {
1027 for (j = 0; j < l; j++) {
1033 cout << l <<
" times file "
1042 cout <<
" for a total of " << sz <<
" char" << endl;
1045 delete [] type_first;
1049 delete [] frequency;
1052 cout <<
"mem_object_registry::sort_by_location_and_get_frequency" << endl;
1058 int f_v = (verbose_level >= 1);
1062 cout <<
"mem_object_registry::sort_by_type" << endl;
1066 cout <<
"mem_object_registry::sort_by_type "
1067 "before Heapsort" << endl;
1072 registry_key_pair_compare_by_type);
1075 cout <<
"mem_object_registry::sort_by_type "
1076 "after Heapsort" << endl;
1080 cout <<
"mem_object_registry::sort_by_type "
1088 int f_v = (verbose_level >= 1);
1092 cout <<
"mem_object_registry::sort_by_location" << endl;
1096 cout <<
"mem_object_registry::sort_by_location "
1097 "before Heapsort" << endl;
1102 registry_key_pair_compare_by_location);
1105 cout <<
"mem_object_registry::sort_by_location "
1106 "after Heapsort" << endl;
1110 cout <<
"mem_object_registry::sort_by_location "
1121static int registry_key_pair_compare_by_size(
void *K1v,
void *K2v)
1134static int registry_key_pair_compare_by_type(
void *K1v,
void *K2v)
1136 int t1, t2, l1, l2, c;
1137 mem_object_registry_entry *K1, *K2;
1139 K1 = (mem_object_registry_entry *) K1v;
1140 K2 = (mem_object_registry_entry *) K2v;
1142 t2 = K2->object_type;
1149 c = strcmp(K1->extra_type_info, K2->extra_type_info);
1154 c = strcmp(K1->source_file, K2->source_file);
1158 l1 = K1->source_line;
1159 l2 = K2->source_line;
1164static int registry_key_pair_compare_by_location(
void *K1v,
void *K2v)
1167 mem_object_registry_entry *K1, *K2;
1169 K1 = (mem_object_registry_entry *) K1v;
1170 K2 = (mem_object_registry_entry *) K2v;
1171 c = strcmp(K1->source_file, K2->source_file);
1175 l1 = K1->source_line;
1176 l2 = K2->source_line;
a collection of functions related to sorted vectors
void int_vec_sorting_permutation(int *v, int len, int *perm, int *perm_inv, int f_increasingly)
void Heapsort(void *v, int len, int entry_size_in_chars, int(*compare_func)(void *v1, void *v2))
a class related to mem_object_registry
void print_csv(std::ostream &ost, int line)
const char * extra_type_info
void print_type(std::ostream &ost)
void add_to_registry(void *pointer, int object_type, long int object_n, int object_size_of, const char *extra_type_info, const char *source_file, int source_line, int verbose_level)
long int ** allocate_plint(long int n, const char *file, int line)
void free_pvoid(void **p, const char *file, int line)
int *** allocate_ppint(long int n, const char *file, int line)
void manual_dump_with_file_name(const char *fname)
uchar * allocate_uchar(long int n, const char *file, int line)
void init(int verbose_level)
void free_uchar(uchar *p, const char *file, int line)
int automatic_dump_interval
void free_char(char *p, const char *file, int line)
void ** allocate_pvoid(long int n, const char *file, int line)
void sort_by_location_and_get_frequency(int verbose_level)
void sort_by_type(int verbose_level)
long int * allocate_lint(long int n, const char *file, int line)
uchar ** allocate_puchar(long int n, const char *file, int line)
void accumulate_and_ignore_duplicates(int verbose_level)
void allocate(int N, int verbose_level)
char * allocate_char(long int n, const char *file, int line)
void free_lint(long int *p, const char *file, int line)
long int *** allocate_pplint(long int n, const char *file, int line)
mem_object_registry_entry * entries
void free_int(int *p, const char *file, int line)
void free_pplint(long int ***p, const char *file, int line)
void sort_by_size(int verbose_level)
void free_pchar(char **p, const char *file, int line)
char automatic_dump_fname_mask[1000]
void free_OBJECTS(void *p, const char *file, int line)
int * allocate_int(long int n, const char *file, int line)
void * allocate_OBJECTS(void *p, long int n, std::size_t size_of, const char *extra_type_info, const char *file, int line)
char ** allocate_pchar(long int n, const char *file, int line)
void sort_by_location(int verbose_level)
void set_automatic_dump(int automatic_dump_interval, const char *fname_mask, int verbose_level)
void free_plint(long int **p, const char *file, int line)
void free_ppint(int ***p, const char *file, int line)
int search(void *p, int &idx)
void delete_from_registry(void *pointer, int verbose_level)
void dump_to_csv_file(const char *fname)
void free_puchar(uchar **p, const char *file, int line)
void * allocate_OBJECT(void *p, std::size_t size_of, const char *extra_type_info, const char *file, int line)
void free_OBJECT(void *p, const char *file, int line)
int ** allocate_pint(long int n, const char *file, int line)
void free_pint(int **p, const char *file, int line)
int memory_debug_verbose_level
#define Int_vec_copy(A, B, C)
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects
#define POINTER_TYPE_puchar
#define POINTER_TYPE_uchar
#define POINTER_TYPE_pplint
#define POINTER_TYPE_pint
#define POINTER_TYPE_lint
#define POINTER_TYPE_ppint
#define POINTER_TYPE_OBJECTS
#define POINTER_TYPE_pchar
#define POINTER_TYPE_PVOID
#define POINTER_TYPE_OBJECT
#define POINTER_TYPE_char
#define POINTER_TYPE_plint