| 87 | // |
| 88 | |
| 89 | UCHAR* MSC_alloc(int size) |
| 90 | { |
| 91 | size = FB_ALIGN(size, FB_ALIGNMENT); |
| 92 | |
| 93 | if (!space || size > space->spc_remaining) |
| 94 | { |
| 95 | const int n = MAX(size, 4096); |
| 96 | gpre_space* next = (gpre_space*) gds__alloc((SLONG) (n + sizeof(gpre_space))); |
| 97 | if (!next) |
| 98 | CPR_error("virtual memory exhausted"); |
| 99 | #ifdef DEBUG_GDS_ALLOC |
| 100 | // For V4.0 we don't care about gpre specific memory leaks |
| 101 | gds_alloc_flag_unfreed(next); |
| 102 | #endif |
| 103 | next->spc_next = space; |
| 104 | next->spc_remaining = n; |
| 105 | space = next; |
| 106 | } |
| 107 | |
| 108 | space->spc_remaining -= size; |
| 109 | UCHAR* blk = ((UCHAR*) space + sizeof(gpre_space) + space->spc_remaining); |
| 110 | memset(blk, 0, size); |
| 111 | |
| 112 | return blk; |
| 113 | } |
| 114 | |
| 115 | |
| 116 | //____________________________________________________________ |
no test coverage detected