static event_count = 0;      if ((event_count++ % SPINNER_UPDATE_FREQUENCY) == 0) printf("\rReading... %c", SPINNER_CHAR(event_count));
tmEventHandler(tmreader * aReader, tmevent * aEvent){    if (NULL != aReader && NULL != aEvent) {        switch (aEvent->type) {            /*             ** Events we ignore.             */        case TM_EVENT_LIBRARY:        case TM_EVENT_METHOD:        case TM_EVENT_STATS:        case TM_EVENT_TIMESTAMP:        case TM_EVENT_FILENAME:            break;            /*             ** Allocation events need to be tracked.             */        case TM_EVENT_MALLOC:        case TM_EVENT_CALLOC:        case TM_EVENT_REALLOC:        case TM_EVENT_FREE:            {                PRUint32 oldptr = 0;                PRUint32 oldsize = 0;                tmcallsite *callsite = NULL;                tmcallsite *oldcallsite = NULL;                if (TM_EVENT_REALLOC == aEvent->type) {                    /*                     ** Only care about old arguments if there were any.                     */                    if (0 != aEvent->u.alloc.oldserial) {                        oldptr = aEvent->u.alloc.oldptr;                        oldsize = aEvent->u.alloc.oldsize;                        oldcallsite =                            tmreader_callsite(aReader,                                              aEvent->u.alloc.oldserial);                        if (NULL == oldcallsite) {                            REPORT_ERROR(__LINE__, tmreader_callsite);                        }                    }                }                callsite = tmreader_callsite(aReader, aEvent->serial);                if (NULL != callsite) {                    /*                     ** Verify a callsite run is there.                     ** If not, we are ignoring this callsite.                     */                    if (NULL != CALLSITE_RUN(callsite)) {                        char eventType = aEvent->type;                        PRUint32 eventSize = aEvent->u.alloc.size;                        /*                         ** Play a nasty trick on reallocs of size zero.                         ** They are to become free events, adjust the size accordingly.                         ** This allows me to avoid all types of special case code.                         */                        if (0 == aEvent->u.alloc.size                            && TM_EVENT_REALLOC == aEvent->type) {                            eventType = TM_EVENT_FREE;                            if (0 != aEvent->u.alloc.oldserial) {                                eventSize = aEvent->u.alloc.oldsize;                            }                        }                        trackEvent(ticks2msec                                   (aReader, aEvent->u.alloc.interval),                                   eventType, ticks2usec(aReader,                                                         aEvent->u.alloc.                                                         cost), callsite,                                   aEvent->u.alloc.ptr, eventSize,                                   oldcallsite, oldptr, oldsize);                    }                }                else {                    REPORT_ERROR(__LINE__, tmreader_callsite);                }            }            break;            /*             ** Callsite, set up the callsite run if it does not exist.             */        case TM_EVENT_CALLSITE:            {                tmcallsite *callsite =                    tmreader_callsite(aReader, aEvent->serial);                if (NULL != callsite) {                    if (NULL == CALLSITE_RUN(callsite)) {                        int createrun = __LINE__;#if defined(MOZILLA_CLIENT)                        /*                         ** For a mozilla spacetrace, ignore this particular                         **  callsite as it is just noise, and causes us to                         **  use a lot of memory.                         **                         ** This callsite is present on the linux build,                         **  not sure if the other platforms have it.                         */                        if (0 !=                            hasCallsiteMatch(callsite, "g_main_is_running",                                             ST_FOLLOW_PARENTS)) {                            createrun = 0;                        }#endif /* MOZILLA_CLIENT */                        if (0 != createrun) {                            callsite->data = createRun(NULL, 0);                        }                    }                }                else {                    REPORT_ERROR(__LINE__, tmreader_callsite);                }            }            break;            /*             ** Unhandled events should not be allowed.             */        default:            {                REPORT_ERROR(__LINE__, tmEventHandler);            }            break;        }    }}