void yFifoCleanup(yFifoBuf *buf) { #ifdef YFIFO_USE_MUTEX yDeleteCriticalSection(&(buf->cs)); #endif memset(buf,0,sizeof(yFifoBuf)); }
void ySafeMemoryStop(void) { yDeleteCriticalSection(&yMapCS); free(yMap); yMap=NULL; yMapSize = yMapUsed = 0; }
static void stopHIDManager(OSX_HID_REF *hid) { if (hid->manager) { IOHIDManagerClose(hid->manager, kIOHIDOptionsTypeNone ); CFRelease( hid->manager); hid->manager=NULL; yDeleteCriticalSection(&hid->hidMCS); } }
void yyyPacketShutdown(yInterfaceSt *iface) { yEnterCriticalSection(&iface->yyyCS); if(iface->devref!=NULL){ IOHIDDeviceRegisterInputReportCallback( iface->devref, // IOHIDDeviceRef for the HID device (u8*) &iface->tmprxpkt, // pointer to the report data (uint8_t's) USB_PKT_SIZE, // number of bytes in the report (CFIndex) NULL, // the callback routine iface); // context passed to callback IOHIDDeviceClose(iface->devref, kIOHIDOptionsTypeNone); iface->devref=NULL; } yLeaveCriticalSection(&iface->yyyCS); yDeleteCriticalSection(&iface->yyyCS); yyyFreePktQueue(iface); }
int yUSB_stop(yContextSt *ctx,char *errmsg) { if ( ctx->hidM ) { IOHIDManagerUnscheduleFromRunLoop(ctx->hidM, ctx->usb_run_loop, kCFRunLoopDefaultMode); CFRelease( ctx->hidM ); ctx->hidM=NULL; } if(ctx->usb_thread_state == USB_THREAD_RUNNING){ ctx->usb_thread_state = USB_THREAD_MUST_STOP; CFRunLoopStop(ctx->usb_run_loop); } pthread_join(ctx->usb_thread,NULL); YASSERT(ctx->usb_thread_state == USB_THREAD_STOPED); yDeleteCriticalSection(&ctx->hidMCS); yReleaseGlobalAccess(ctx); return 0; }
int yyyUSB_stop(yContextSt *ctx,char *errmsg) { int i; stringCacheSt *c = stringCache; if(ctx->usb_thread_state == USB_THREAD_RUNNING){ ctx->usb_thread_state = USB_THREAD_MUST_STOP; pthread_join(ctx->usb_thread,NULL); } YASSERT(ctx->usb_thread_state == USB_THREAD_STOPED); libusb_exit(ctx->libusb); yReleaseGlobalAccess(ctx); for (i = 0; i < STRING_CACHE_SIZE; i++, c++) { if(c->string) { yFree(c->string); } } yDeleteCriticalSection(&ctx->string_cache_cs); return YAPI_SUCCESS; }