...
| Code Block | ||
|---|---|---|
| ||
enum { BLOCK_HEADER_SIZE = 16 };
unsigned long long max = UINT_MAX;
void *AllocateBlock(size_t length) {
struct memBlock *mBlock;
if (length + BLOCK_HEADER_SIZE > max) return NULL;
mBlock
= (struct memBlock *)malloc(length + BLOCK_HEADER_SIZE);
if (!mBlock) return NULL;
/* fill in block header and return data portion */
return mBlock;
}
|
...
| Code Block | ||
|---|---|---|
| ||
enum { BLOCK_HEADER_SIZE = 16 };
unsigned long long max = UINT_MAX;
void *AllocateBlock(size_t length) {
struct memBlock *mBlock;
if ((unsigned long long)length + BLOCK_HEADER_SIZE > max)
return NULL;
mBlock
= (struct memBlock *)malloc(length + BLOCK_HEADER_SIZE);
if (!mBlock) return NULL;
/* fill in block header and return data portion */
return mBlock;
}
|
...