@@ -23,8 +23,8 @@ void fossil_mock_init(fossil_mock_calllist_t *list) {
2323 if (!list ) {
2424 return ;
2525 }
26- list -> head = null ;
27- list -> tail = null ;
26+ list -> head = NULL ;
27+ list -> tail = NULL ;
2828 list -> size = 0 ;
2929}
3030
@@ -47,12 +47,12 @@ void fossil_mock_destroy(fossil_mock_calllist_t *list) {
4747 pizza_sys_memory_free (current );
4848 current = next ;
4949 }
50- list -> head = null ;
51- list -> tail = null ;
50+ list -> head = NULL ;
51+ list -> tail = NULL ;
5252 list -> size = 0 ;
5353}
5454
55- void fossil_mock_add_call (fossil_mock_calllist_t * list , const char * function_name , char * * arguments , int num_args ) {
55+ void fossil_mock_add_call (fossil_mock_calllist_t * list , const char * function_name , fossil_mock_pizza_t * arguments , int num_args ) {
5656 if (!list || !function_name || !arguments ) {
5757 return ;
5858 }
@@ -68,18 +68,28 @@ void fossil_mock_add_call(fossil_mock_calllist_t *list, const char *function_nam
6868 return ;
6969 }
7070
71- call -> arguments = (fossil_mock_pizza_t * )malloc (num_args * sizeof (fossil_mock_pizza_t ));
71+ call -> arguments = (fossil_mock_pizza_t * )pizza_sys_memory_alloc (num_args * sizeof (fossil_mock_pizza_t ));
7272 if (!call -> arguments ) {
7373 pizza_sys_memory_free (call -> function_name );
7474 pizza_sys_memory_free (call );
7575 return ;
7676 }
7777
7878 for (int i = 0 ; i < num_args ; ++ i ) {
79- call -> arguments [i ].value .data = pizza_io_cstr_dup (arguments [i ]);
80- if (!call -> arguments [i ].value .data ) {
81- for (int j = 0 ; j < i ; ++ j ) {
79+ call -> arguments [i ].type = arguments [i ].type ;
80+ call -> arguments [i ].value .data = pizza_io_cstr_dup (arguments [i ].value .data );
81+ call -> arguments [i ].value .mutable_flag = arguments [i ].value .mutable_flag ;
82+ call -> arguments [i ].attribute .name = pizza_io_cstr_dup (arguments [i ].attribute .name );
83+ call -> arguments [i ].attribute .description = pizza_io_cstr_dup (arguments [i ].attribute .description );
84+ call -> arguments [i ].attribute .id = pizza_io_cstr_dup (arguments [i ].attribute .id );
85+
86+ if (!call -> arguments [i ].value .data || !call -> arguments [i ].attribute .name ||
87+ !call -> arguments [i ].attribute .description || !call -> arguments [i ].attribute .id ) {
88+ for (int j = 0 ; j <= i ; ++ j ) {
8289 pizza_sys_memory_free (call -> arguments [j ].value .data );
90+ pizza_sys_memory_free (call -> arguments [j ].attribute .name );
91+ pizza_sys_memory_free (call -> arguments [j ].attribute .description );
92+ pizza_sys_memory_free (call -> arguments [j ].attribute .id );
8393 }
8494 pizza_sys_memory_free (call -> arguments );
8595 pizza_sys_memory_free (call -> function_name );
@@ -89,7 +99,7 @@ void fossil_mock_add_call(fossil_mock_calllist_t *list, const char *function_nam
8999 }
90100
91101 call -> num_args = num_args ;
92- call -> next = null ;
102+ call -> next = NULL ;
93103
94104 if (list -> tail ) {
95105 list -> tail -> next = call ;
@@ -108,14 +118,15 @@ void fossil_mock_print(fossil_mock_calllist_t *list) {
108118 fossil_mock_call_t * current = list -> head ;
109119 while (current ) {
110120 pizza_io_printf ("Function: %s\n" , current -> function_name );
111- pizza_io_printf ("Arguments: " );
121+ pizza_io_printf ("Arguments:\n " );
112122 for (int i = 0 ; i < current -> num_args ; ++ i ) {
113- pizza_io_printf ("%s" , current -> arguments [i ]);
114- if (i < current -> num_args - 1 ) {
115- pizza_io_printf (", " );
116- }
123+ pizza_io_printf (" Type: %d\n" , current -> arguments [i ].type );
124+ pizza_io_printf (" Value: %s\n" , current -> arguments [i ].value .data );
125+ pizza_io_printf (" Mutable: %s\n" , current -> arguments [i ].value .mutable_flag ? "true" : "false" );
126+ pizza_io_printf (" Attribute Name: %s\n" , current -> arguments [i ].attribute .name );
127+ pizza_io_printf (" Attribute Description: %s\n" , current -> arguments [i ].attribute .description );
128+ pizza_io_printf (" Attribute ID: %s\n" , current -> arguments [i ].attribute .id );
117129 }
118- pizza_io_printf ("\n" );
119130 current = current -> next ;
120131 }
121132}
0 commit comments