allocate lb bytes for an object of kind k. */ Should not be used to directly to allocate */ objects such as STUBBORN objects that */ require special handling on allocation. */ First a version that assumes we already */ hold lock: */
| 99 | /* First a version that assumes we already */ |
| 100 | /* hold lock: */ |
| 101 | void * GC_generic_malloc_inner(size_t lb, int k) |
| 102 | { |
| 103 | void *op; |
| 104 | |
| 105 | if(SMALL_OBJ(lb)) { |
| 106 | struct obj_kind * kind = GC_obj_kinds + k; |
| 107 | size_t lg = GC_size_map[lb]; |
| 108 | void ** opp = &(kind -> ok_freelist[lg]); |
| 109 | |
| 110 | if( (op = *opp) == 0 ) { |
| 111 | if (GC_size_map[lb] == 0) { |
| 112 | if (!GC_is_initialized) GC_init_inner(); |
| 113 | if (GC_size_map[lb] == 0) GC_extend_size_map(lb); |
| 114 | return(GC_generic_malloc_inner(lb, k)); |
| 115 | } |
| 116 | if (kind -> ok_reclaim_list == 0) { |
| 117 | if (!GC_alloc_reclaim_list(kind)) goto out; |
| 118 | } |
| 119 | op = GC_allocobj(lg, k); |
| 120 | if (op == 0) goto out; |
| 121 | } |
| 122 | *opp = obj_link(op); |
| 123 | obj_link(op) = 0; |
| 124 | GC_bytes_allocd += GRANULES_TO_BYTES(lg); |
| 125 | } else { |
| 126 | op = (ptr_t)GC_alloc_large_and_clear(ADD_SLOP(lb), k, 0); |
| 127 | GC_bytes_allocd += lb; |
| 128 | } |
| 129 | |
| 130 | out: |
| 131 | return op; |
| 132 | } |
| 133 | |
| 134 | /* Allocate a composite object of size n bytes. The caller guarantees */ |
| 135 | /* that pointers past the first page are not relevant. Caller holds */ |
no test coverage detected