Skip to content

Commit a8eb00b

Browse files
committed
debugging: phase 2 - creating MLD objects
1 parent 9771150 commit a8eb00b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

mld.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ void print_structure_rec(struct_db_rec_t *struct_rec) {
6868
void print_structure_db(struct_db_t *struct_db) {
6969
if(!struct_db) return;
7070

71-
printf("Printing Structure Database");
71+
printf("\n" ANSI_COLOR_RED "Printing Structure Database" ANSI_COLOR_RESET);
7272
struct_db_rec_t *struct_rec = NULL;
7373
struct_rec = struct_db->head;
74-
printf("No of Structures Registered = %d\n", struct_db->count);
74+
printf("\nNo of Structures Registered = %d\n", struct_db->count);
7575
int i = 0;
7676
while(struct_rec) {
7777
printf("structure no : %d (%p)\n", i++, struct_rec);
@@ -110,7 +110,7 @@ static struct_db_rec_t
110110

111111
static object_db_rec_t
112112
*object_db_look_up(object_db_t *object_db, void *ptr) {
113-
object_db_rec_t *head = object->head;
113+
object_db_rec_t *head = object_db->head;
114114
if(!head) return NULL;
115115
for (; head; head = head->next) {
116116
if(head->ptr == ptr)
@@ -142,7 +142,6 @@ static void add_object_to_object_db(object_db_t *object_db,
142142

143143
if(!head) {
144144
object_db->head = obj_rec;
145-
object->next = NULL;
146145
object_db->count++;
147146
return;
148147
}
@@ -156,23 +155,23 @@ void *xcalloc(object_db_t *object_db, char *struct_name, int uints) {
156155
assert(struct_rec);
157156

158157
void *ptr = calloc(uints, struct_rec->ds_size);
159-
add_object_to_object_db(object_db, ptr, uints, strutc_rec, MLD_FALSE);
158+
add_object_to_object_db(object_db, ptr, uints, struct_rec, MLD_FALSE);
160159
return ptr;
161160
}
162161

163162
/* Print functions for object database */
164163
void print_object_rec(object_db_rec_t *obj_rec, int i) {
165164
if(!obj_rec) return;
166-
printf(ANSI_COLOR_MAGENTA "--------------------------|\n" ANSI_COLOR_RESET);
165+
printf(ANSI_COLOR_MAGENTA "-------------------------------------------------------------------------------------------------------------|\n" ANSI_COLOR_RESET);
167166
printf(ANSI_COLOR_YELLOW "%-3d ptr = %-10p | next = %-10p | units = %-4d | struct_name = %-10s | is_root = %s |\n" ANSI_COLOR_RESET, i, obj_rec->ptr, obj_rec->next, obj_rec->units, obj_rec->struct_rec->struct_name, obj_rec->is_root ? "TRUE" : "FALSE");
168-
printf(ANSI_COLOR_MAGENTA "--------------------------|\n" ANSI_COLOR_RESET);
167+
printf(ANSI_COLOR_MAGENTA "-------------------------------------------------------------------------------------------------------------|\n" ANSI_COLOR_RESET);
169168
}
170169

171170
void print_object_db(object_db_t *object_db) {
172171
object_db_rec_t *head = object_db->head;
173172
unsigned int i = 0;
174-
printf(ANSI_COLOR_CYAN "Printing OBJECT DATABASE\n");
175-
for(; head; head->next) {
173+
printf("\n" ANSI_COLOR_CYAN "PRINTING OBJECT DATABASE\n" ANSI_COLOR_RESET);
174+
for(; head; head = head->next) {
176175
print_object_rec(head, i++);
177176
}
178177
}

0 commit comments

Comments
 (0)