Browse code

core: pvapi - reinitialize _pv_print_buffer_index when adjusting the slots

- GH #2798

(cherry picked from commit 61cbb5e861aeb9b7f69ebb8d284e3ded0ede9cd8)

Daniel-Constantin Mierla authored on 27/07/2021 14:52:12
Showing 1 changed files
... ...
@@ -2147,6 +2147,7 @@ int pv_init_buffer(void)
2147 2147
 			_pv_print_buffer_slots, _pv_print_buffer_size);
2148 2148
 	_pv_print_buffer_slots_active = _pv_print_buffer_slots;
2149 2149
 	_pv_print_buffer_size_active = _pv_print_buffer_size;
2150
+	_pv_print_buffer_index = 0;
2150 2151
 
2151 2152
 	return 0;
2152 2153
 }
... ...
@@ -2168,6 +2169,7 @@ void pv_destroy_buffer(void)
2168 2169
 	pkg_free(_pv_print_buffer);
2169 2170
 	_pv_print_buffer_slots_active = 0;
2170 2171
 	_pv_print_buffer_size_active = 0;
2172
+	_pv_print_buffer_index = 0;
2171 2173
 	_pv_print_buffer = NULL;
2172 2174
 }
2173 2175
 
... ...
@@ -2177,8 +2179,9 @@ void pv_destroy_buffer(void)
2177 2179
 int pv_reinit_buffer(void)
2178 2180
 {
2179 2181
 	if(_pv_print_buffer_size==_pv_print_buffer_size_active
2180
-			&& _pv_print_buffer_slots==_pv_print_buffer_slots_active)
2182
+			&& _pv_print_buffer_slots==_pv_print_buffer_slots_active) {
2181 2183
 		return 0;
2184
+	}
2182 2185
 	pv_destroy_buffer();
2183 2186
 	return pv_init_buffer();
2184 2187
 }