Is there a way of checking if memory pointed to by pointer has been initialized?(not necessarily by my program).
Thanks
views:
116answers:
4
A:
By "initialized" you probably mean "allocated". In any case: no, it isn't possible.
If the pointer is NULL, you can say it wasn't initialized for sure, however :-)
Eli Bendersky
2010-03-31 15:28:31
A:
Not really. You might be able to do something low-level and OS-specific, like see if touching the memory generates a page fault, but I can't believe that anyone would seriously contemplate doing something like this when there must be a better overall solution.
Paul R
2010-03-31 15:29:25
+8
A:
No.
Uninitialized memory can contain anything, including bytes that make it look like it has been initialized.
James McNellis
2010-03-31 15:29:42
A:
The only way would be to define a "not initialized value", such as 0x0 (just because), and use that inside your application, setting all the memory you ask for with that value.
In general, no, not possible.
Tom
2010-03-31 15:30:34