Guys from the MOTO made a re-test of Touchscreen Analysis and this time using a robot ;)
Guess who won the latest tests?
But of course.... iPhone wins again.
..EDG reports that their experience in the field has been that nearly no one actually uses the feature, and that it would be right (and okay with EDG) to deprecate or remove it...
malloc_zone_t *zone = malloc_default_zone();Don't forget to check for errors, and check that you got your zone.
...
static malloc_zone_t original_zone;
...
original_zone = *zone;
system_malloc = zone->malloc;
system_free = zone->free;
zone->malloc = &my_malloc;
zone->free = &my_free;
void *(*system_malloc)(malloc_zone_t *zone, size_t size);
...
void (*system_free)(malloc_zone_t *zone, void *ptr);
...
void my_free(malloc_zone_t *zone, void *ptr)
{
malloc_printf("free(zone=%p, ptr=%p)\n", zone, ptr);
system_free(zone, ptr); // or if you save the whole zone: (*original_zone.free)(zone, ptr);
}
and so on...
void
free(void *ptr) {
malloc_zone_t *zone;
size_t size;
if (!ptr)
return;
zone = find_registered_zone(ptr, &size);
if (!zone) {
malloc_printf("*** error for object %p: pointer being freed was not allocated\n"
"*** set a breakpoint in malloc_error_break to debug\n", ptr);
malloc_error_break();
if ((malloc_debug_flags & (SCALABLE_MALLOC_ABORT_ON_CORRUPTION|SCALABLE_MALLOC_ABORT_ON_ERROR)))
abort();
} else if (zone->version >= 6 && zone->free_definite_size)
malloc_zone_free_definite_size(zone, ptr, size);
else
malloc_zone_free(zone, ptr);
}
system_free_definite_size = zone->free_definite_size;
zone->free_definite_size = my_free_definite_size;
#
# Check that malloc_zone_t has the free_definite_size memeber
#
if(APPLE)
include(CheckCSourceCompiles)
check_c_source_compiles("
#include
void main () {
malloc_zone_t zone;
zone.free_definite_size = NULL;
}
" APPLE_MALLOC_ZONE_FREE_DEFINITE_SIZE)
endif(APPLE)
#if defined(APPLE_MALLOC_ZONE_FREE_DEFINITE_SIZE)
if (zone->version >= 6 && zone->free_definite_size)
{
system_free_definite_size = zone->free_definite_size;
zone->free_definite_size = my_free_definite_size;
}
#endif