#!/bin/bash -ex
#
#         Patching needed to enable the memory module
#         ===========================================
#
# For the time being, some patching is needed to enable the memory module.
# Execute the following from the modules/documentation directory to bootstrap.
# Only run once!

cd ../../..
TOP="`pwd`"

cd $TOP/modules/hardcore/base
cvs up -j mortenro_20070522_memory_module baseincludes.h
cvs up -j mortenro_20070821_memory_module system.txt

cd $TOP/modules/hardcore/features
cvs up -j mortenro_20070605_memory_module features.txt

cd $TOP/platforms/core
cvs up -j mortenro_20070821_memory_module tweaks.h
cvs up -j mortenro_20070625_memory_module features.h

cd $TOP/platforms/lingogi
cvs up -j mortenro_20070821_memory_module system.h

cd $TOP/platforms/lingogi/driver
cvs up -j mortenro_20070605_memory_module gogi_driver_main.cpp

cd $TOP/modules
echo "memory         HEAD" >> readme.txt

exit 0
#
# End of functioning script
#


Raw Notes on the memory module
==============================

Questions:

* Should we allow global variables as a tweak, to possibly speed things
  up on platforms that supports it (and possibly improve memory debugging
  accuracy/coverage)?

* Introduce OP_SYSDELETE which sets a function pointer to cause the
  system de-allocator to be called?  Probably not - it will cause bad
  performance.

* In memory constrained builds; use lea_malloc to allocate the desired
  number of bytes, but allocate memory with memory guards in
  "debug" memory?  This will give correct OOM prediction and pooling
  efficiency measurements, but also allows memory guards.

* Let op_free and OP_DELETE set the pointer to the freed memory to some
  invalid value to cause a crash in debugging builds?

* Should the memory guard function also be made available when we
  provide lea_malloc for all to use, including the platform?

* Would there be any point in starting to use a delete operator from a
  class like 'OpMem' to get a different delete operator?
  It would make it possible to detect delete operations that are not
  done through OP_DELETE, and they may also help separate the Opera
  allocator and that of the system.
  This will probably only yield a real benefit once all delete's are
  changed into OP_DELETE.


Use cases:

1) Debug on desktop

   Enable:
    * Global operator new
    * memory debugging
    * memory guards
   Requires:
    * global variables

2) Debug on desktop with Phone profile on Windows (or Linux)

   Enable:
    * Global operator new
    * memory debugging
    * memory guards
    * constrained memory
   Requires:
    * global variables
    * lea_malloc

3) Debug on desktop with Phone profile on Linux (with inlined new for testing)

   Enable:
    * Inlined operator new
    * memory debugging
    * memory guards
    * constrained memory
   Requires:
    * lea_malloc

4) Release on desktop

   ... no specific configuration

5) Debug on Phone

   Enable:
    * Inlined operator new
    * memory debugging

