...
| Code Block | ||
|---|---|---|
| ||
enum { BLOCK_HEADER_SIZE = 16 };
void *AllocateBlock(size_t length) {
struct memBlock *mBlock;
if (length + BLOCK_HEADER_SIZE > (unsigned long long) 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;
}
|
GCC Compiler Version 3.4.4 produces a warning for this non-compliant code example.
Compliant Solution
...