coverity[+alloc] */
| 59 | |
| 60 | /* coverity[+alloc] */ |
| 61 | void *MALLOC(size_t size) |
| 62 | { |
| 63 | void *res; |
| 64 | assert(size>0); |
| 65 | /* Warning, memory leak checker must be posix_memalign/memalign aware, otherwise * |
| 66 | * reports may look strange. Aligned memory is required if the buffer is * |
| 67 | * used for read/write operation with a file opened with O_DIRECT */ |
| 68 | #if defined(HAVE_POSIX_MEMALIGN) |
| 69 | if(size>=512) |
| 70 | { |
| 71 | if(posix_memalign(&res,4096,size)==0) |
| 72 | { |
| 73 | memset(res,0,size); |
| 74 | return res; |
| 75 | } |
| 76 | } |
| 77 | #elif defined(HAVE_MEMALIGN) |
| 78 | if(size>=512) |
| 79 | { |
| 80 | if((res=memalign(4096, size))!=NULL) |
| 81 | { |
| 82 | memset(res,0,size); |
| 83 | return res; |
| 84 | } |
| 85 | } |
| 86 | #endif |
| 87 | #ifdef DISABLED_FOR_FRAMAC |
| 88 | if((res=calloc(1,size))==NULL) |
| 89 | { |
| 90 | exit(EXIT_FAILURE); |
| 91 | } |
| 92 | #else |
| 93 | if((res=malloc(size))==NULL) |
| 94 | { |
| 95 | log_critical("\nCan't allocate %lu bytes of memory.\n", (long unsigned)size); |
| 96 | log_close(); |
| 97 | exit(EXIT_FAILURE); |
| 98 | } |
| 99 | memset(res,0,size); |
| 100 | #endif |
| 101 | /*@ assert \valid((char *)res + (0 .. size - 1)); */ |
| 102 | return res; |
| 103 | } |
| 104 | |
| 105 | #ifndef HAVE_SNPRINTF |
| 106 | int snprintf(char *str, size_t size, const char *format, ...) |
no test coverage detected