LCOV - code coverage report
Current view: top level - seahorn/lib - fuzz_allocators.c (source / functions) Hit Total Coverage
Test: all_fuzz.info Lines: 30 30 100.0 %
Date: 2021-04-23 16:28:21 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  */
       4             : 
       5             : #include <proof_allocators.h>
       6             : #include "sea_allocators.h"
       7             : #include <stdarg.h>
       8             : #include <stdlib.h>
       9             : 
      10             : // for assume()
      11             : #include <seahorn/seahorn.h> 
      12             : 
      13     4698147 : void *bounded_malloc(size_t size) { return malloc(size); }
      14             : 
      15    13894184 : void *can_fail_malloc(size_t size) { return malloc(size); }
      16             : 
      17       20463 : void *sea_malloc_safe(size_t sz) {
      18       20463 :   void *p = malloc(sz);
      19       20463 :   assume(p);
      20       20463 :   return p;
      21       20463 : }
      22             : 
      23             : #define AWS_ALIGN_ROUND_UP(value, alignment) \
      24      149280 :   (((value) + ((alignment)-1)) & ~((alignment)-1))
      25             : 
      26      149280 : INLINE void *sea_malloc_aligned(size_t sz) {
      27      149280 :   enum { S_ALIGNMENT = sizeof(intmax_t) };
      28      149280 :   size_t alloc_sz = AWS_ALIGN_ROUND_UP(sz, S_ALIGNMENT);
      29      149280 :   return malloc(alloc_sz);
      30      149280 : }
      31             : #undef AWS_ALIGN_ROUND_UP
      32             : 
      33      149280 : void *sea_malloc_aligned_havoc(size_t sz) {
      34      149280 :   void *data = sea_malloc_aligned(sz);
      35      149280 :   if (data)
      36      149280 :     memhavoc(data, sz);
      37      149280 :   return data;
      38      149280 : }
      39             : 
      40             : /**
      41             :  *
      42             :  */
      43      887990 : static void *s_malloc_allocator(struct aws_allocator *allocator, size_t size) {
      44      887990 :   (void)allocator;
      45      887990 :   return bounded_malloc(size);
      46      887990 : }
      47             : 
      48             : /**
      49             :  */
      50      687040 : static void s_free_allocator(struct aws_allocator *allocator, void *ptr) {
      51      687040 :   (void)allocator;
      52      687040 :   free(ptr);
      53      687040 : }
      54             : 
      55             : static struct aws_allocator s_allocator_fuzz_static = {
      56             :     .mem_acquire = s_malloc_allocator,
      57             :     .mem_release = s_free_allocator,
      58             :     .mem_realloc = NULL,
      59             :     .mem_calloc = NULL,
      60             : };
      61             : 
      62    14737899 : struct aws_allocator *sea_allocator() {
      63    14737899 :   return &s_allocator_fuzz_static;
      64    14737899 : }

Generated by: LCOV version 1.13