/** * Initializes the event system. * <p> * <b>NOTE:</b> The event system must be explicitly initialize so the * VM can shutdown and restart cleanly. * * @return 0 for success, or non-zero if the MIDP implementation is * out of memory */ int InitializeEvents(void) { int sizeInBytes; if (NULL != pEventQueues) { /* already done */ return 0; } #if ENABLE_MULTIPLE_ISOLATES maxIsolates = JVM_MaxIsolates(); #endif sizeInBytes = maxIsolates * sizeof (EventQueue); pEventQueues = midpMalloc(sizeInBytes); if (NULL == pEventQueues) { return -1; } memset(pEventQueues, 0, sizeInBytes); midp_createEventQueueLock(); return 0; }
/** * Initializes the event system. * <p> * <b>NOTE:</b> The event system must be explicitly initialize so the * VM can shutdown and restart cleanly. * * @return 0 for success, or non-zero if the MIDP implementation is * out of memory */ int InitializeEvents(void) { int sizeInBytes; if (NULL != gsEventQueues) { /* already done */ return 0; } #if ENABLE_MULTIPLE_ISOLATES gsMaxIsolates = getMaxIsolates(); /* * In MVM the first isolate has number 1, but 0 still can be returned * by midpGetAmsIsolate() if JVM is not running. So in MVM we allocate * one more entry in gsEventQueues[] to make indices from 0 to maxIsolates * inclusively valid. */ gsTotalQueues = gsMaxIsolates + 1; #else gsTotalQueues = 1; #endif #if ENABLE_EVENT_SPYING gsEventSpyingQueueId = gsTotalQueues; gsTotalQueues += 1; #endif sizeInBytes = gsTotalQueues * sizeof (EventQueue); gsEventQueues = midpMalloc(sizeInBytes); if (NULL == gsEventQueues) { return -1; } memset(gsEventQueues, 0, sizeInBytes); midp_createEventQueueLock(); return 0; }