您好,登錄后才能下訂單哦!
typedef struct MsgData { SLIST_ENTRY NextEntry;//下一個(gè)結(jié)點(diǎn) INT ID; char buff[20]; }STDATA,*PSTDATA; void CtestThreadDlg::OnBnClickedButton17() { PSLIST_ENTRY pListFirstItem,pListItem; PSLIST_HEADER pHead; //創(chuàng)建頭結(jié)點(diǎn) pHead = (PSLIST_HEADER)_aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT); //初始化頭結(jié)點(diǎn) InitializeSListHead(pHead); //新結(jié)點(diǎn)數(shù)據(jù) PSTDATA stPdata = (PSTDATA)_aligned_malloc(sizeof(STDATA), MEMORY_ALLOCATION_ALIGNMENT); stPdata->ID = 1200; strcpy_s(stPdata->buff, 20,"message"); //添加到隊(duì)列中,從頭添加節(jié)點(diǎn),返回前一個(gè)節(jié)點(diǎn) pListFirstItem = InterlockedPushEntrySList(pHead, &stPdata->NextEntry); pListItem = InterlockedPopEntrySList(pHead);//從頭部取出數(shù)據(jù) PSTDATA pData = (PSTDATA)pListItem; CString str(pData->buff); TRACE(str+_T("\n")); _aligned_free(pListItem);//釋放內(nèi)存 InterlockedFlushSList(pHead); pListItem = InterlockedPopEntrySList(pHead); if (pListItem == NULL) { TRACE(_T("已清空\n")); } _aligned_free(pHead); }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。