Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

lib
Class OverrunProtector

   in allocators.h

template < class T > class OverrunProtector

OverrunProtector wraps an arbitrary object in DynArray memory and can detect inadvertent writes to it. this is useful for tracking down memory overruns. the basic idea is to require users to request access to the object and notify us when done; memory access permission is temporarily granted. (similar in principle to Software Transaction Memory). since this is quite slow, the protection is disabled unless CONFIG_OVERRUN_PROTECTION == 1; this avoids having to remove the wrapper code in release builds and re-write when looking for overruns. example usage: OverrunProtector your_class_wrapper; .. yc = your_class_wrapper.get(); // unlock, make ready for use if(!yc) // your_class_wrapper's one-time alloc of a your_class- abort(); // instance had failed - can't continue. doSomethingWith(yc); // read/write access your_class_wrapper.lock(); // disallow further access until next .get() ..


Field Summary
private T* cached_ptr
          
private DynArray da
          
private uintptr_t initialized
          
 
Constructor Summary
OverrunProtector()
          
~OverrunProtector()
          
 
Method Summary
 T* get()
          
private void init()
          
 void lock()
          
private void shutdown()
          
private void unlock()
          
 

Field Detail

cached_ptr

private T* cached_ptr;

da

private DynArray da;

initialized

private uintptr_t initialized;


Constructor Detail

OverrunProtector

public OverrunProtector();

~OverrunProtector

public ~OverrunProtector();


Method Detail

get

public T* get();

init

private void init();

lock

public void lock();

shutdown

private void shutdown();

unlock

private void unlock();

 Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
Generated on September 04, 2007 at 18:14
CppDoc v2.4.0
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD