[maemo-commits] [maemo-commits] r12622 - in projects/haf/trunk/libosso: debian src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Jul 3 15:01:33 EEST 2007
- Previous message: [maemo-commits] r12621 - projects/tools/trunk/maemo_testing/maemo-examples
- Next message: [maemo-commits] r12623 - in projects/haf/trunk/sapwood: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2007-07-03 15:01:18 +0300 (Tue, 03 Jul 2007) New Revision: 12622 Modified: projects/haf/trunk/libosso/debian/changelog projects/haf/trunk/libosso/src/osso-mem.c Log: patch from Leonid Modified: projects/haf/trunk/libosso/debian/changelog =================================================================== --- projects/haf/trunk/libosso/debian/changelog 2007-07-03 10:57:05 UTC (rev 12621) +++ projects/haf/trunk/libosso/debian/changelog 2007-07-03 12:01:18 UTC (rev 12622) @@ -2,8 +2,10 @@ * UNRELEASED * Fix some warnings in osso-state.c when using -pedantic + * Patch from Leonid to improve saw_malloc_hook() in osso-mem.c. + Fixes: NB#62391 - -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Thu, 7 Jun 2007 11:30:03 +0300 + -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Tue, 03 Jul 2007 15:00:40 +0300 libosso (2.12-1) unstable; urgency=low Modified: projects/haf/trunk/libosso/src/osso-mem.c =================================================================== --- projects/haf/trunk/libosso/src/osso-mem.c 2007-07-03 10:57:05 UTC (rev 12621) +++ projects/haf/trunk/libosso/src/osso-mem.c 2007-07-03 12:01:18 UTC (rev 12622) @@ -274,23 +274,26 @@ * ------------------------------------------------------------------------- */ static void* saw_malloc_hook(size_t size, const void* caller) { - void* ptr; /* Allocated pointer, NULL means OOM situation happened */ + static unsigned count = 0; /* Validation count per number of allocations */ + void* ptr; /* Allocated pointer, NULL means OOM situation happened */ THREAD_LOCK(); /* Restore the real malloc hook */ __malloc_hook = saw_old_malloc_hook; - /* Check for OOM-potential situation */ - if (size >= saw_max_block_size) + /* Check for OOM-potential situation by size or allocated blocks counter */ + if (size >= saw_max_block_size || !count) { /* We must test amount of memory to predict future */ const struct mallinfo mi = mallinfo(); - ptr = (mi.arena + mi.hblkhd + size >= saw_max_heap_size ? NULL : malloc(size)); + ptr = (mi.arena + mi.hblkhd + size >= saw_max_heap_size || osso_mem_in_lowmem_state() ? NULL : malloc(size)); + count = 1024; } else { ptr = malloc(size); + count--; } /* Restore malloc hook to self */ @@ -298,8 +301,12 @@ /* Test allocation, call OOM function if necessary */ /* Note: SAW may be removed but that is safe for us */ - if (!ptr && saw_user_oom_func) - saw_user_oom_func(saw_max_heap_size + size, saw_max_heap_size, saw_user_context); + if ( !ptr ) + { + count = 0; /* force the next validation */ + if (saw_user_oom_func) + saw_user_oom_func(saw_max_heap_size + size, saw_max_heap_size, saw_user_context); + } THREAD_UNLOCK();
- Previous message: [maemo-commits] r12621 - projects/tools/trunk/maemo_testing/maemo-examples
- Next message: [maemo-commits] r12623 - in projects/haf/trunk/sapwood: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]