CSoftKeyboard::~CSoftKeyboard() /*++ Routine Description: Destructor for CSoftKeyboard Synchronization: None Arguments: None Return Value: None --*/ { // Stop internal thread (void)End(); // Release the softtranslator interface RELEASE(m_piSoftKbdTranslator); // Release IMalloc interface RELEASE(m_pMalloc); //Initialize the member variables InitMemberVariables(); } // CSoftKeyboard::~CSoftKeyboard
MemBuffer::MemBuffer(const vector<uint8_t> &initData) : Trackable(Trackable::OBJ_MEMBUFFER) { InitMemberVariables(); Init(initData.size(), false); uint8_t *bufPtr = GetBuffer(); for (size_t i = 0; i < initData.size(); i++, bufPtr++) *bufPtr = initData[i]; }
void MemBuffer::DeallocateResources() { // Either new or posix_memalign() was used to allocate memory if (mAllocByNewOperator) { if (mRealBaseAddr) delete [] mRealBaseAddr; } else { if (mRealBaseAddr) free(mRealBaseAddr); } InitMemberVariables(); }
CLoopbackDevice::~CLoopbackDevice() { // Release the conneciton point ReleaseConnectionPoint(); // Release any interface which the device is holding RELEASE(m_piConnectionPoint); RELEASE(m_piINEndpoint); RELEASE(m_piOUTEndpoint); if (NULL != m_piSoftUSBDevice) { (void)m_piSoftUSBDevice->Destroy(); RELEASE(m_piSoftUSBDevice); } InitMemberVariables(); }
// CSoftHIDInputKbdMapper // SoftHIDInputKbdMapper Class implementation CSoftHIDInputKbdMapper::CSoftHIDInputKbdMapper() /*++ Routine Description: Constructor for CSoftHIDInputKbdMapper Synchronization: None Arguments: None Return Value: None --*/ { InitMemberVariables(); } // CSoftHIDInputKbdMapper::CSoftHIDInputKbdMapper
//SoftKeyboard Class implementation CSoftKeyboard::CSoftKeyboard() /*++ Routine Description: Constructor for CSoftKeyboard Synchronization: None Arguments: None Return Value: None --*/ { InitMemberVariables(); } // CSoftKeyboard::CSoftKeyboard
void MemBuffer::InitOffset1stPage(uint32_t bufSize, uint32_t offset1stPg, bool initMem, uint8_t initVal) { int err; uint32_t realBufSize; uint32_t align = sysconf(_SC_PAGESIZE); LOG_NRM( "Init buffer; size: 0x%08X, offset: 0x%08X, init: %d, value: 0x%02X", bufSize, offset1stPg, initMem, initVal); if (offset1stPg % sizeof(uint32_t) != 0) { throw FrmwkEx(HERE, "Offset into page 1 not aligned to: 0x%02lX", sizeof(uint32_t)); } // Support resizing/reallocation if (mRealBaseAddr != NULL) DeallocateResources(); mAllocByNewOperator = false; // using posix_memalign() // All memory is allocated page aligned, offsets into the 1st page requires // asking for more memory than the caller desires and then tracking the // virtual pointer into the real allocation as a side affect. mVirBufSize = bufSize; realBufSize = (bufSize + offset1stPg); err = posix_memalign((void **)&mRealBaseAddr, align, realBufSize); if (err) { InitMemberVariables(); throw FrmwkEx(HERE, "Memory allocation failed with error code: 0x%02X", err); } mVirBaseAddr = (mRealBaseAddr + offset1stPg); if (offset1stPg) mAlignment = offset1stPg; else mAlignment = align; if (initMem) memset(mVirBaseAddr, initVal, mVirBufSize); }
CSoftHIDInputKbdMapper::~CSoftHIDInputKbdMapper() /*++ Routine Description: Destructor for CSoftHidInputKbdMapper Synchronization: None Arguments: None Return Value: None --*/ { // Stop internal thread (void)CMessageTask::End(); // Disconnect event sink from the source TearDownEventSink(m_piConnectionPointKbd, m_dwKbdSinkCookie); // Release the ISoftHIDProtocolXlator interface RELEASE(m_piSoftProtXlator); // Release the ISoftKeyboard interface RELEASE(m_piSoftKeyboard); // Release IMalloc interface RELEASE(m_pMalloc); // Delete safearray with Report Descriptor data if (NULL != m_psaReportDescriptor) { (void)::SafeArrayDestroy(m_psaReportDescriptor); m_psaReportDescriptor = NULL; } // Initialize the member variables InitMemberVariables(); } // CSoftHIDInputKbdMapper::~CSoftHIDInputKbdMapper
void MemBuffer::InitAlignment(uint32_t bufSize, uint32_t align, bool initMem, uint8_t initVal, volatile uint8_t *srcBuffer) { int err; LOG_NRM("Init buffer; size: 0x%08X, align: 0x%08X, init: %d, value: 0x%02X", bufSize, align, initMem, initVal); if (align % sizeof(void *) != 0) { throw FrmwkEx(HERE, "Req'd alignment 0x%08X, is not modulo 0x%02lX", align, sizeof(void *)); } // Support resizing/reallocation if (mRealBaseAddr != NULL) DeallocateResources(); mAllocByNewOperator = false; // using posix_memalign() mVirBufSize = bufSize; err = posix_memalign((void **)&mRealBaseAddr, align, mVirBufSize); if (err) { InitMemberVariables(); throw FrmwkEx(HERE, "Memory allocation failed with error code: 0x%02X", err); } mVirBaseAddr = mRealBaseAddr; mAlignment = align; if (srcBuffer != NULL) { //memcpy(mVirBaseAddr, buffer, bufSize ); for(uint32_t dataIndex = 0; dataIndex < bufSize; dataIndex++) { mVirBaseAddr[dataIndex] = (volatile uint8_t) srcBuffer[dataIndex]; } } else if (initMem) { memset(mVirBaseAddr, initVal, mVirBufSize); } }
void MemBuffer::Init(uint32_t bufSize, bool initMem, uint8_t initVal) { LOG_NRM("Init buffer; size: 0x%08X, init: %d, value: 0x%02X", bufSize, initMem, initVal); // Support resizing/reallocation if (mRealBaseAddr != NULL) DeallocateResources(); mAllocByNewOperator = true; mVirBufSize = bufSize; mRealBaseAddr = new (nothrow) uint8_t[mVirBufSize]; if (mRealBaseAddr == NULL) { InitMemberVariables(); throw FrmwkEx(HERE, "Memory allocation failed"); } mVirBaseAddr = mRealBaseAddr; mAlignment = 0; if (initMem) memset(mVirBaseAddr, initVal, mVirBufSize); }
CLoopbackDevice::CLoopbackDevice() { InitMemberVariables(); }
MemBuffer::MemBuffer() : Trackable(Trackable::OBJ_MEMBUFFER) { InitMemberVariables(); }