void asyncDeallocateAlarmData (AsyncAlarmData *ad) { if (ad) { if (ad->alarmQueue) deallocateQueue(ad->alarmQueue); free(ad); } }
static void spk_destruct (volatile SpeechSynthesizer *spk) { stopSynthesisThread(); closeSoundDevice(); if (speechQueue) { deallocateQueue(speechQueue); speechQueue = NULL; } if (speechChannel) { if (mpChannelExit) mpChannelExit(speechChannel, NULL, 0); speechChannel = NULL; } #ifdef ENABLE_SHARED_OBJECTS if (speechLibrary) { const SymbolEntry *symbol = symbolTable; while (symbol->name) { void **address = (symbol++)->address; *address = NULL; } unloadSharedObject(speechLibrary); speechLibrary = NULL; } #endif /* ENABLE_SHARED_OBJECTS */ }
static void usbDeallocateEndpoint (void *item, void *data) { UsbEndpoint *endpoint = item; switch (USB_ENDPOINT_DIRECTION(endpoint->descriptor)) { case UsbEndpointDirection_Input: if (endpoint->direction.input.pending) { deallocateQueue(endpoint->direction.input.pending); endpoint->direction.input.pending = NULL; } if (endpoint->direction.input.completed) { free(endpoint->direction.input.completed); endpoint->direction.input.completed = NULL; } break; } if (endpoint->extension) { usbDeallocateEndpointExtension(endpoint->extension); endpoint->extension = NULL; } free(endpoint); }
KeyboardMonitorObject * newKeyboardMonitorObject (const KeyboardProperties *properties, KeyEventHandler handleKeyEvent) { KeyboardMonitorObject *kmo; if ((kmo = malloc(sizeof(*kmo)))) { memset(kmo, 0, sizeof(*kmo)); kmo->requiredProperties = *properties; kmo->handleKeyEvent = handleKeyEvent; if (newKeyboardMonitorExtension(&kmo->kmx)) { if ((kmo->instanceQueue = newQueue(NULL, NULL))) { if (monitorKeyboards(kmo)) { kmo->isActive = 1; return kmo; } deallocateQueue(kmo->instanceQueue); } destroyKeyboardMonitorExtension(kmo->kmx); } free(kmo); } else { logMallocError(); } return NULL; }
void asyncDeallocateIoData (AsyncIoData *iod) { if (iod) { if (iod->functionQueue) deallocateQueue(iod->functionQueue); free(iod); } }
static void deallocateFunctionEntry (void *item, void *data) { FunctionEntry *function = item; if (function->operations) deallocateQueue(function->operations); if (function->methods->endFunction) function->methods->endFunction(function); free(function); }
void usbDeallocateEndpointExtension (UsbEndpointExtension *eptx) { if (eptx->completedRequests) { deallocateQueue(eptx->completedRequests); eptx->completedRequests = NULL; } free(eptx); }
void destroyKeyboardMonitorObject (KeyboardMonitorObject *kmo) { kmo->isActive = 0; while (getQueueSize(kmo->instanceQueue) > 0) { Element *element = getQueueHead(kmo->instanceQueue); KeyboardInstanceObject *kio = getElementItem(element); destroyKeyboardInstanceObject(kio); } if (kmo->instanceQueue) deallocateQueue(kmo->instanceQueue); if (kmo->kmx) destroyKeyboardMonitorExtension(kmo->kmx); free(kmo); }
static Element * getFunctionElement (FileDescriptor fileDescriptor, const FunctionMethods *methods, int create) { Queue *functions = getFunctionQueue(create); if (functions) { { FunctionKey key = { .fileDescriptor = fileDescriptor, .methods = methods }; { Element *element = findElement(functions, testFunctionEntry, &key); if (element) return element; } } if (create) { FunctionEntry *function; if ((function = malloc(sizeof(*function)))) { function->fileDescriptor = fileDescriptor; function->methods = methods; if ((function->operations = newQueue(deallocateOperationEntry, NULL))) { { static AsyncQueueMethods methods = { .cancelRequest = cancelOperation }; setQueueData(function->operations, &methods); } if (methods->beginFunction) methods->beginFunction(function); { Element *element = enqueueItem(functions, function); if (element) return element; } deallocateQueue(function->operations); } free(function); } else {
static void usbDeallocateEndpoint (void *item, void *data) { UsbEndpoint *endpoint = item; switch (USB_ENDPOINT_DIRECTION(endpoint->descriptor)) { case UsbEndpointDirection_Input: if (endpoint->direction.input.pending.alarm) { asyncCancelRequest(endpoint->direction.input.pending.alarm); endpoint->direction.input.pending.alarm = NULL; } if (endpoint->direction.input.pending.requests) { deallocateQueue(endpoint->direction.input.pending.requests); endpoint->direction.input.pending.requests = NULL; } if (endpoint->direction.input.completed.request) { free(endpoint->direction.input.completed.request); endpoint->direction.input.completed.request = NULL; } break; default: break; } if (endpoint->extension) { usbDeallocateEndpointExtension(endpoint->extension); endpoint->extension = NULL; } switch (USB_ENDPOINT_DIRECTION(endpoint->descriptor)) { case UsbEndpointDirection_Input: usbDestroyInputPipe(endpoint); break; default: break; } free(endpoint); }
void usbDeallocateEndpointExtension (UsbEndpointExtension *eptx) { if (eptx->status != -1) { close(eptx->status); eptx->status = -1; } if (eptx->data != -1) { close(eptx->data); eptx->data = -1; } if (eptx->name) { free(eptx->name); eptx->name = NULL; } if (eptx->requests) { deallocateQueue(eptx->requests); eptx->requests = NULL; } free(eptx); }
int usbAllocateEndpointExtension (UsbEndpoint *endpoint) { UsbDevice *device = endpoint->device; UsbDeviceExtension *devx = device->extension; UsbEndpointExtension *eptx; if ((eptx = malloc(sizeof(*eptx)))) { if ((eptx->requests = newQueue(NULL, NULL))) { int flags; { char name[0X80]; int length = 0; if (devx->configuration != 1) { int count; sprintf(&name[length], "cfg%d%n", devx->configuration, &count); length += count; } { int count; sprintf(&name[length], "if%d%n", devx->interface, &count); length += count; } if (devx->alternative != 0) { int count; sprintf(&name[length], ".%d%n", devx->alternative, &count); length += count; } { const UsbEndpointDescriptor *descriptor = endpoint->descriptor; UsbEndpointDirection direction = USB_ENDPOINT_DIRECTION(descriptor); const char *prefix; switch (direction) { case UsbEndpointDirection_Input: prefix = "in"; flags = O_RDONLY; break; case UsbEndpointDirection_Output: prefix = "out"; flags = O_WRONLY; break; default: logMessage(LOG_ERR, "USB unsupported endpoint direction: %02X", direction); goto nameError; } { int count; sprintf(&name[length], "%s%d%n", prefix, USB_ENDPOINT_NUMBER(descriptor), &count); length += count; } } eptx->name = strdup(name); } if (eptx->name) { if (usbOpenEndpointFiles(devx->path, eptx->name, &eptx->data, &eptx->status, flags)) { endpoint->extension = eptx; return 1; } free(eptx->name); } nameError: deallocateQueue(eptx->requests); } free(eptx); } return 0; }