
13 Apr
2011
13 Apr
'11
1:07 a.m.
On 4/12/2011 5:43 PM, Phil Bouchard wrote:
On 4/12/2011 4:06 PM, Phil Bouchard wrote:
Is that so? I guess it'll be different if you have:
struct Silly { bool is_from_heap(const char* p) { return heap<= p&& p< heap + sizeof(heap); }
char data[1024]; char heap[1024]; char stack[1024]; };
... and "p" is guaranteed to be part of either the data, heap or stack buffer.
To embellish the structure it could be renamed to: struct { pool data, heap, stack; } process; Where the default implementation of the global operator ::new could be: void * operator new(size_t n) { return ::process.heap.malloc(n); } If you call is_from() with a pointer p then pointer p is guaranteed to be part of one of the pools mentioned above. -Phil