This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

callback functionality for dyanmic memory allocation


The following patches allows a user to track:

1) heap creation
2) heap destruction
3) allocation/freeing of dynamic memory
    and
4) reallocation of dynamic memory (i.e. realloc functionality)

Included is the CDL to control it.  By default it is turned off.  There will 
be a performance penalty to turn on the logging ability even if you do not 
use it since a pointer must be checked (the callback).

Example usage is:

  // varriable sized heaps
  Cyg_Mempool_Variable::set_create_cb     (var_create);
  Cyg_Mempool_Variable::set_destroy_cb    (var_destroy);
  Cyg_Mempool_Variable::set_pre_alloc_cb  (var_pre_alloc);
  Cyg_Mempool_Variable::set_post_alloc_cb (var_post_alloc);
  Cyg_Mempool_Variable::set_pre_free_cb   (var_pre_free);
  Cyg_Mempool_Variable::set_post_free_cb  (var_post_free);

  // dlmalloc heaps
  Cyg_Mempool_dlmalloc::set_create_cb     (var_create);
  Cyg_Mempool_dlmalloc::set_destroy_cb    (var_destroy);
  Cyg_Mempool_dlmalloc::set_pre_alloc_cb  (var_pre_alloc);
  Cyg_Mempool_dlmalloc::set_post_alloc_cb (var_post_alloc);
  Cyg_Mempool_dlmalloc::set_pre_free_cb   (var_pre_free);
  Cyg_Mempool_dlmalloc::set_post_free_cb  (var_post_free);

  // fixed size block allocator heaps
  Cyg_Mempool_Fixed::set_create_cb     (fix_create);
  Cyg_Mempool_Fixed::set_destroy_cb    (fix_destroy);
  Cyg_Mempool_Fixed::set_pre_alloc_cb  (fix_pre_alloc);
  Cyg_Mempool_Fixed::set_post_alloc_cb (fix_post_alloc);
  Cyg_Mempool_Fixed::set_pre_free_cb   (fix_pre_free);
  Cyg_Mempool_Fixed::set_post_free_cb  (fix_post_free);

The additional functionality will allow a user to keep track of every 
allocation in the system, as well as to modify allocated memory to add 
padding to detect array overflows.

Diff files attached.

-Rich

Attachment: diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]