| 69 | }; |
| 70 | |
| 71 | static void _hpt_malloc(unsigned int frag_overhead) |
| 72 | { |
| 73 | struct hpt_frag *ret; |
| 74 | ssize_t size; |
| 75 | |
| 76 | if (!check_limit()) { |
| 77 | should_grow = 0; |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | size = (rand() % HPT_FAC) * (HPT_MAX_ALLOC_SZ/HPT_FAC) + 1; |
| 82 | |
| 83 | ret = MALLOC(sizeof *ret + size); |
| 84 | if (!ret) { |
| 85 | LM_ERR("oom\n"); |
| 86 | should_grow = 0; |
| 87 | return; |
| 88 | } |
| 89 | memset(ret, -1, sizeof *ret + size); |
| 90 | |
| 91 | if ((unsigned long)ret % MEM_ALIGN == 0) |
| 92 | aligned_mallocs++; |
| 93 | |
| 94 | ret->chunk = (void *)(ret + 1); |
| 95 | ret->size = size; |
| 96 | |
| 97 | list_add(&ret->list, &hpt_frags); |
| 98 | |
| 99 | hpt_my_used += size + sizeof *ret + frag_overhead; |
| 100 | mallocs++; |
| 101 | fragments++; |
| 102 | } |
| 103 | |
| 104 | static void _hpt_realloc(unsigned int frag_overhead) |
| 105 | { |
no test coverage detected