本文整理汇总了C++中ReleaseResource函数的典型用法代码示例。如果您正苦于以下问题:C++ ReleaseResource函数的具体用法?C++ ReleaseResource怎么用?C++ ReleaseResource使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReleaseResource函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NextValue_runtime
StatusType NextValue_runtime(thread_queue_t * global_q, int port_id, void * dst)
{
StatusType status = E_OK;
struct port_queue_t *port_q = (struct port_queue_t*) global_q->port_queues[port_id];
status = GetResource(*(global_q->rez));
if (status != E_OK)
return status;
if(port_q->first_idx == port_q->last_idx)
{
if(port_q->blocking)
{
global_q->waiting=global_q->waiting+1;
ReleaseResource(*(global_q->rez));
status = WaitEvent(*(global_q->event));
GetResource(*(global_q->rez));
global_q->waiting=global_q->waiting-1;
}
else
{
ReleaseResource(*(global_q->rez));
return E_OS_LIMIT;
}
}
if(port_q->first_idx < port_q->last_idx)
port_q->first_idx=(port_q->first_idx+1)%port_q->queue_size;
memcpy(dst, &port_q->offset[(port_q->first_idx)*(port_q->msg_size/sizeof(char))], port_q->msg_size);
global_q->msg_nb--;
ReleaseResource(*(global_q->rez));
return status;
}
示例2: main
//主进程
void main(void)
{
//创建Opengl渲染环境及窗口
char *device = "opengl";
HCoreResizeFunc( ResizeWindow );
HCoreCreateWindow(100, 100, 800, 600, device);
if ( !HCoreInitGraphicsDevice(device) )
{
printf("初始化失败 \n", device);
exit(0);
}
//注册输入函数
HCoreInputInit();
HCoreRegisterKeyDown(HCoreKEY_0, KeyDown_0);
HCoreRegisterKeyDown(HCoreKEY_1, KeyDown_1);
HCoreRegisterKeyDown(HCoreKEY_2, KeyDown_2);
HCoreRegisterKeyDown(HCoreKEY_3, KeyDown_3);
HCoreRegisterKeyDown(HCoreKEY_4, KeyDown_4);
HCoreRegisterKeyDown(HCoreKEY_5, KeyDown_5);
HCoreRegisterKeyDown(HCoreKEY_6, KeyDown_6);
HCoreRegisterKeyDown(HCoreKEY_7, KeyDown_7);
HCoreRegisterKeyDown(HCoreKEY_8, KeyDown_8);
HCoreRegisterKeyDown(HCoreKEY_9, KeyDown_9);
//设置相机
g_Control.SetCamera(Vector4(0.0f, 0.0f, 1.0f), Vector4(0.0f, 1.0f, 1.0f), Vector4(0.0f, 0.0f, 1.0f) );
//读取模型
//地形
g_Model.Load_ASCII("..\\models\\terrain.gma");
//棋盘
g_SSAOModel.Load_ASCII("..\\models\\chess.gma");
// 载入shader
if ( !InitResource() )
{
ReleaseResource();
exit(0);
}
// 主循环
while( HCoreProcessMessage() )
{
GetUserInput();
RenderFrame();
}
// 释放shader
ReleaseResource();
// 关闭OpenGL绘图设备
HCoreReleaseGraphicsDevice();
}
示例3: ReleaseAnimatedCursors
void ReleaseAnimatedCursors( void )
{
short i;
if ( gCursorList )
{
for ( i = 0; i< (*gCursorList)->numberOfFrames; i++ )
ReleaseResource( (Handle) (*gCursorList)->frame[i] );
ReleaseResource( (Handle) gCursorList );
}
}
示例4: ShowLogo
void
ShowLogo(Boolean bEraseRect)
{
short reserr;
Rect derefd, logoRect;
PicHandle logoPicH;
Handle logoRectH;
/* draw the image well */
ControlHandle imgWellH = GetNewControl(rLogoImgWell, gWPtr);
if (!imgWellH)
{
ErrorHandler(eMem, nil);
return;
}
/* initialize Netscape logo */
logoPicH = GetPicture(rNSLogo);
reserr = ResError();
if (reserr == noErr)
{
/* draw Netscape logo */
if (logoPicH != nil)
{
logoRectH = GetResource('RECT', rNSLogoBox);
reserr = ResError();
if (reserr == noErr && logoRectH)
{
HLock(logoRectH);
derefd = (Rect) **((Rect**)logoRectH);
SetRect(&logoRect, derefd.left, derefd.top, derefd.right, derefd.bottom);
HUnlock(logoRectH);
reserr = ResError();
if (reserr == noErr)
{
if (bEraseRect)
{
EraseRect(&logoRect);
InvalRect(&logoRect);
}
DrawPicture(logoPicH, &logoRect);
ReleaseResource((Handle)logoPicH);
}
ReleaseResource((Handle)logoRectH);
}
}
}
if (reserr != noErr)
ErrorHandler(reserr, nil);
}
示例5: NameCacheFree
BOOLEAN
NameCacheFree(PKLG_NAME_CACHE pNameCache, ULONG key)
{
PNAMECACHE Entry;
PNAMECACHE Prev;
ULONG i;
if (pNameCache == NULL)
return FALSE;
Prev = NULL;
i = HASH_FUNC(key);
AcquireResource(&pNameCache->m_CacheResource, TRUE);
Entry=pNameCache->m_NameCache[i];
while(Entry && Entry->Key!=key)
{
Prev=Entry;
Entry=Entry->Next;
}
if(!Entry)
{
DbPrint(DC_NAMEC,DL_SPAM, ("CacheFree-%x %x not found. NCLen=%d\n",pNameCache,key,pNameCache->m_NCLen));
ReleaseResource(&pNameCache->m_CacheResource);
return FALSE;
}
Entry->RefCount--;
if(Entry->RefCount)
{
DbPrint(DC_NAMEC,DL_INFO, ("CacheFree-%x. Owner=%x Ref decr for key %x ("_STRING_DEF") NCLen=%d\n",
pNameCache, Entry->Owner, Entry->Key, Entry->Name, pNameCache->m_NCLen));
ReleaseResource(&pNameCache->m_CacheResource);
return TRUE;
}
if(Prev)
Prev->Next = Entry->Next;
else
pNameCache->m_NameCache[i]=Entry->Next;
#ifdef __DBG__
pNameCache->m_NCLen--;
pNameCache->m_NameCacheLen[i]--;
DbPrint(DC_NAMEC,DL_INFO, ("CacheFree-%x. Owner=%x Freed key %x ("_STRING_DEF") NCLen=%d\n", pNameCache,
Entry->Owner, Entry->Key, Entry->Name, pNameCache->m_NCLen));
#endif
ReleaseResource(&pNameCache->m_CacheResource);
ExFreePool(Entry);
return TRUE;
}
示例6: wxMacStringToPascal
wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
{
m_refData = new wxCursorRefData;
if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE )
{
Str255 theName ;
wxMacStringToPascal( cursor_file , theName ) ;
wxStAppResource resload ;
Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ;
if ( resHandle )
{
short theId = -1 ;
OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_isColorCursor = true ;
}
else
{
Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ;
if ( resHandle )
{
short theId = -1 ;
OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_releaseHandle = true ;
}
}
}
else
{
wxImage image ;
image.LoadFile( cursor_file , flags ) ;
if( image.Ok() )
{
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X,hotSpotX ) ;
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y,hotSpotY ) ;
delete m_refData ;
CreateFromImage(image) ;
}
}
}
示例7: IndResourceExists
// Pass resFile as -1 to use the current resource file
// true = exists
Boolean IndResourceExists(short resFile,ResType resType,short inIndex)
{
short oldRes=::CurResFile();
Handle theRes=0L;
if (resFile!=-1)
{
UseResFile(resFile);
if (ResError())
return false;
}
SetResLoad(false);
theRes=Get1IndResource(resType,inIndex);
SetResLoad(true);
UseResFile(oldRes);
if (theRes)
{
ReleaseResource(theRes);
return true;
}
else
return false;
}
示例8: NameCacheGetReplaceBinary
VOID
NameCacheGetReplaceBinary(PKLG_NAME_CACHE pNameCache, ULONG key, PVOID Value, DWORD ValueLen)
{
PVOID pRet = NULL;
BOOLEAN bOverBuf = FALSE;
if (pNameCache == NULL)
{
DbPrint(DC_NAMEC,DL_SPAM, ("NameCacheReplaceBinary: wrong internal status - NULL\n"));
return;
}
AcquireResource(&pNameCache->m_CacheResource, FALSE);
pRet = NameCacheGetBase(pNameCache, key, NULL, ValueLen, &bOverBuf, FALSE, NULL);
if (bOverBuf == TRUE)
{
DbPrint(DC_NAMEC, DL_WARNING, ("NameCacheReplaceBunary: size mismatch\n"));
DbgBreakPoint();
}
else
{
if (pRet != NULL)
memcpy(pRet, Value, ValueLen);
}
ReleaseResource(&pNameCache->m_CacheResource);
}
示例9: NameCacheClean
VOID
NameCacheClean(PKLG_NAME_CACHE pNameCache)
{
ULONG i;
PNAMECACHE Tmp,Entry;
if (pNameCache == NULL)
{
DbPrint(DC_NAMEC,DL_INFO, ("NameCacheClean: wrong internal status - NULL\n"));
return;
}
AcquireResource(&pNameCache->m_CacheResource, TRUE);
for(i =0; i < HASH_SIZE; i++)
{
Entry=pNameCache->m_NameCache[i];
while(Entry)
{
Tmp=Entry->Next;
ExFreePool(Entry);
Entry = Tmp;
#ifdef __DBG__
pNameCache->m_NCLen--;
pNameCache->m_NameCacheLen[i]--;
#endif
}
pNameCache->m_NameCache[i] = NULL;
}
DbPrint(DC_NAMEC,DL_NOTIFY, ("CacheCleanup-%x. NCLen=%d\n",pNameCache,pNameCache->m_NCLen));
ReleaseResource(&pNameCache->m_CacheResource);
}
示例10: GetConfig
OSErr GetConfig(Ptr config)
{
OSErr error = noErr;
FSSpec where;
short ref;
Handle theString;
Ptr temp = nil;
long len;
config[0] = '\0'; // Start without a name
error = FindPrefs(&where);
ref = FSpOpenResFile(&where, fsRdWrPerm);
if (ref != -1) {
theString = Get1Resource('STR ',kConfigRes); // Should look in most recent file first
if (theString != nil) {
len = SizeResource(theString);
SetPtrSize(config, len); // Set the size
error = MemError(); // And make sure it worked
if (error == noErr) {
HLock(theString);
temp = (Ptr)*theString;
memcpy(config, temp, len);
HUnlock(theString);
ReleaseResource(theString);
}
} else {
error = -4;
}
CloseResFile(ref);
} else {
error = ResError();
}
return error;
}
示例11: test_t1_instance2
/*test case:test the reaction of the system called with
an activation of a task*/
static void test_t1_instance2(void)
{
ApplicationType result_app_1;
StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4;
ScheduleTableStatusType ScheduleTableStatusType_inst_1;
TickType TickType_inst_1;
SCHEDULING_CHECK_INIT(10);
result_app_1 = GetApplicationID();
SCHEDULING_CHECK_AND_EQUAL_INT(10, app1, result_app_1);
SCHEDULING_CHECK_INIT(11);
result_inst_1 = GetAlarm(Alarm1, &TickType_inst_1);
SCHEDULING_CHECK_AND_EQUAL_INT(11, E_OS_NOFUNC, result_inst_1);
SCHEDULING_CHECK_INIT(12);
result_inst_2 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_1);
SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(12 , SCHEDULETABLE_STOPPED , ScheduleTableStatusType_inst_1);
SCHEDULING_CHECK_AND_EQUAL_INT(12, E_OK, result_inst_2);
SCHEDULING_CHECK_INIT(13);
result_inst_3 = ReleaseResource(Resource1);
SCHEDULING_CHECK_AND_EQUAL_INT(13, E_OS_NOFUNC, result_inst_3);
SCHEDULING_CHECK_INIT(14);
result_inst_4 = TerminateApplication(app1, NO_RESTART);
SCHEDULING_CHECK_AND_EQUAL_INT(140, E_OK, result_inst_4);
}
示例12: J2dTraceLn
HRESULT
D3DResourceManager::GetLockableRTSurface(UINT width, UINT height,
D3DFORMAT format,
D3DResource **ppSurfaceResource)
{
HRESULT res = S_OK;
J2dTraceLn(J2D_TRACE_INFO, "D3DRM::GetLockableRTSurface");
RETURN_STATUS_IF_NULL(pCtx, E_FAIL);
RETURN_STATUS_IF_NULL(ppSurfaceResource, E_FAIL);
if (pLockableRTSurface != NULL) {
D3DSURFACE_DESC *pDesc = pLockableRTSurface->GetDesc();
if (width <= pDesc->Width && height <= pDesc->Height &&
format == pDesc->Format)
{
*ppSurfaceResource = pLockableRTSurface;
return res;
}
// current surface doesn't fit, release and allocate a new one
ReleaseResource(pLockableRTSurface);
pLockableRTSurface = NULL;
}
if (width < D3DC_BLIT_TILE_SIZE) width = D3DC_BLIT_TILE_SIZE;
if (height < D3DC_BLIT_TILE_SIZE) height = D3DC_BLIT_TILE_SIZE;
res = CreateRTSurface(width,height,
(format != D3DFMT_A8R8G8B8), TRUE /*lockable*/,
&format, &pLockableRTSurface);
*ppSurfaceResource = pLockableRTSurface;
return res;
}
示例13: createOffscreen
void createOffscreen(int pictItem)
{
PicHandle pict;
Rect rect;
CGrafPtr currentPort;
GDHandle currentDevice;
if (gGWorld != nil)
DisposeGWorld( gGWorld );
pict = (PicHandle)GetResource( 'PICT', pictItem + 127 );
rect = (**pict).picFrame;
GetGWorld( ¤tPort, ¤tDevice );
NewGWorld( &gGWorld, 32, &rect, nil, nil, 0 );
LockPixels( GetPortPixMap(gGWorld));
SetGWorld( gGWorld, nil );
DrawPicture( pict, &rect );
SetGWorld( currentPort, currentDevice );
ReleaseResource( (Handle)pict );
}
示例14: ciaaModbus_gatewayAddMaster
extern int8_t ciaaModbus_gatewayAddMaster(
int32_t hModbusGW,
int32_t hModbusMaster)
{
uint32_t loopi;
int8_t ret = -1;
if ( (0 <= hModbusGW) && (0 <= hModbusMaster))
{
/* enter critical section */
GetResource(MODBUSR);
for (loopi = 0 ; (loopi < CIAA_MODBUS_GATEWAY_TOTAL_CLIENTS) && (ret != 0) ; loopi++)
{
if (ciaaModbus_gatewayObj[hModbusGW].client[loopi].inUse == false)
{
ciaaModbus_gatewayObj[hModbusGW].client[loopi].inUse = true;
ciaaModbus_gatewayObj[hModbusGW].client[loopi].handler = hModbusMaster;
ciaaModbus_gatewayObj[hModbusGW].client[loopi].recvMsg = ciaaModbus_masterRecvMsg;
ciaaModbus_gatewayObj[hModbusGW].client[loopi].sendMsg = ciaaModbus_masterSendMsg;
ciaaModbus_gatewayObj[hModbusGW].client[loopi].task = ciaaModbus_masterTask;
ciaaModbus_gatewayObj[hModbusGW].client[loopi].getRespTimeout = ciaaModbus_masterGetRespTimeout;
ret = 0;
}
}
/* exit critical section */
ReleaseResource(MODBUSR);
}
return ret;
}
示例15: WriteThumbnailToResourceFork
void WriteThumbnailToResourceFork(FSRef *ref, int destWidth, int destHeight)
{
OSStatus err;
PicHandle pict;
HFSUniStr255 fork;
SInt16 resf;
err = FSGetResourceForkName(&fork);
if (err == noErr)
{
err = FSCreateResourceFork(ref, fork.length, fork.unicode, 0);
if ((err == noErr) || (err == errFSForkExists))
{
err = FSOpenResourceFile(ref, fork.length, fork.unicode, fsWrPerm, &resf);
if (err == noErr)
{
pict = GetScreenAsPicHandle(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight, destWidth, destHeight);
if (pict)
{
AddResource((Handle) pict, 'PICT', 128, "\p");
WriteResource((Handle) pict);
ReleaseResource((Handle) pict);
}
CloseResFile(resf);
}