| 119 | // |
| 120 | |
| 121 | UCHAR* MSC_alloc_permanent(int size) |
| 122 | { |
| 123 | size = FB_ALIGN(size, FB_ALIGNMENT); |
| 124 | |
| 125 | if (!permanent_space || size > permanent_space->spc_remaining) |
| 126 | { |
| 127 | const int n = MAX(size, 4096); |
| 128 | gpre_space* next = (gpre_space*) gds__alloc((SLONG) (n + sizeof(gpre_space))); |
| 129 | if (!next) |
| 130 | CPR_error("virtual memory exhausted"); |
| 131 | #ifdef DEBUG_GDS_ALLOC |
| 132 | // For V4.0 we don't care about gpre specific memory leaks |
| 133 | gds_alloc_flag_unfreed(next); |
| 134 | #endif |
| 135 | next->spc_next = permanent_space; |
| 136 | next->spc_remaining = n; |
| 137 | permanent_space = next; |
| 138 | } |
| 139 | |
| 140 | permanent_space->spc_remaining -= size; |
| 141 | UCHAR* blk = (UCHAR*) permanent_space + sizeof(gpre_space) + permanent_space->spc_remaining; |
| 142 | memset(blk, 0, size); |
| 143 | |
| 144 | return blk; |
| 145 | } |
| 146 | |
| 147 | |
| 148 | //____________________________________________________________ |
no test coverage detected