+
+ rte_malloc_get_socket_stats(socket,&second_stats);
+
+ rte_free(p2);
+ rte_free(p3);
+
+ /* After freeing both allocations check stats return to original */
+ rte_malloc_get_socket_stats(socket, &post_stats);
+
+ if(second_stats.heap_totalsz_bytes != first_stats.heap_totalsz_bytes) {
+ printf("Incorrect heap statistics: Total size \n");
+ return -1;
+ }
+ /* Check allocated size is equal to two additions plus overhead */
+ if(second_stats.heap_allocsz_bytes !=
+ size + overhead + first_stats.heap_allocsz_bytes) {
+ printf("Incorrect heap statistics: Allocated size \n");
+ return -1;
+ }
+ /* Check that allocation count increments correctly i.e. +1 */
+ if (second_stats.alloc_count != first_stats.alloc_count + 1) {
+ printf("Incorrect heap statistics: Allocated count \n");
+ return -1;
+ }
+
+ if (second_stats.free_count != first_stats.free_count){
+ printf("Incorrect heap statistics: Free count \n");
+ return -1;
+ }
+
+ /* Make sure that we didn't touch our greatest chunk: 2 * 11M) */
+ if (post_stats.greatest_free_size != pre_stats.greatest_free_size) {
+ printf("Incorrect heap statistics: Greatest free size \n");
+ return -1;
+ }
+ /* Free size must equal the original free size minus the new allocation*/
+ if (first_stats.heap_freesz_bytes <= second_stats.heap_freesz_bytes) {
+ printf("Incorrect heap statistics: Free size \n");
+ return -1;
+ }
+
+ if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) &&
+ (post_stats.heap_freesz_bytes!=pre_stats.heap_freesz_bytes) &&
+ (post_stats.heap_allocsz_bytes!=pre_stats.heap_allocsz_bytes)&&
+ (post_stats.alloc_count!=pre_stats.alloc_count)&&
+ (post_stats.free_count!=pre_stats.free_count)) {
+ printf("Malloc statistics are incorrect - freed alloc\n");
+ return -1;
+ }