• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GS_ASSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GS_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ GS_ASSERT函数的具体用法?C++ GS_ASSERT怎么用?C++ GS_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GS_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GS_ASSERT

// for GS_ARENA, count must be 4, 8, 16 or 20
void *__gs_mempool_alloc(unsigned int arena_id, unsigned int count)
{
  gs_arena_t *arena = &gs_mempool[arena_id];
  gs_memblock_t *memblk = arena->lastblock;
  if (memblk == NULL) {
#ifdef TARG_IA64
    // On IA64, the sizeof(gspin_t) is 32
    GS_ASSERT(sizeof(gspin_t) == 32, "struct gspin size has changed.");
#else
    GS_ASSERT(sizeof(gspin_t) == 20, "struct gspin size has changed.");
#endif
    memblk = gs_new_memblock(0);
    arena->firstblock = arena->lastblock = memblk;
    arena->current_index = 0;
  }
  else if ((arena->current_index + count - 1) >=
           ((memblk->block_id + 1) << GS_BLOCK_IDX_SHIFT_AMT)) {
    memblk = gs_new_memblock(memblk->block_id + 1);
    arena->lastblock->next = memblk;
    arena->lastblock = memblk;
    if (count > 1) // this is needed to gaurantee locations to be contiguous
      arena->current_index = memblk->block_id * GS_MEMBLOCK_SIZE;
  }
  gs_void_t *p = &memblk->mem[arena->current_index & GS_OFST_IN_BLK_MASK];
  arena->current_index += count;
  return p;
}
开发者ID:seguljac,项目名称:higpu,代码行数:28,代码来源:gspin-mempool.c


示例2: gsUdpEngineGetPeerOutBufferFreeSpace

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// UDP Layer must be initialized
// theIp and thePort cannot be 0 (Zero)
// Based on an IP and port, the function will return the amount of free space 
// of a peer's buffer.
int gsUdpEngineGetPeerOutBufferFreeSpace(unsigned int theIp, unsigned short thePort)
{
	GSUdpEngineObject *aUdp = gsUdpEngineGetEngine();
	GSUdpRemotePeer aRemotePeer, *aRemotePeerFound;
	int index;
	GS_ASSERT(aUdp->mInitialized);
	GS_ASSERT(theIp);
	GS_ASSERT(thePort);
	if (!aUdp->mInitialized)
	{
		gsDebugFormat(GSIDebugCat_Common, GSIDebugType_Network, GSIDebugLevel_Debug,
			"[Udp Engine] Engine not initialized\n");
		return 0;
	}

	aRemotePeer.mAddr = theIp;
	aRemotePeer.mPort = thePort;
	index = ArraySearch(aUdp->mRemotePeers, &aRemotePeer, gsUdpRemotePeerCompare, 0, 0);
	if (index != NOT_FOUND)
	{
		aRemotePeerFound = (GSUdpRemotePeer *)ArrayNth(aUdp->mRemotePeers, index);
		return gt2GetOutgoingBufferFreeSpace(aRemotePeerFound->mConnection);
	}
	return 0;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:31,代码来源:gsUdpEngine.c


示例3: gsUdpEngineGetPeerState

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// UDP Layer must be initialized
// Used obtain the peer's state 
// theIp and thePort cannot be 0 (Zero)
GSUdpErrorCode gsUdpEngineGetPeerState(unsigned int theIp, unsigned short thePort, GSUdpPeerState *thePeerState)
{
	GSUdpEngineObject *aUdp = gsUdpEngineGetEngine();
	GSUdpRemotePeer aPeer, *aPeerFound;
	int index;
	GS_ASSERT(aUdp->mInitialized);
	GS_ASSERT(theIp);
	GS_ASSERT(thePort);
	GS_ASSERT(thePeerState != NULL);
	if (!aUdp->mInitialized)
	{
		gsDebugFormat(GSIDebugCat_Common, GSIDebugType_State, GSIDebugLevel_Debug, 
			"[Udp Engine] Engine not initialized\n");
		*thePeerState = GS_UDP_PEER_CLOSED;
		return GS_UDP_NOT_INITIALIZED;
	}

	aPeer.mAddr = theIp;
	aPeer.mPort = thePort;
	index = ArraySearch(aUdp->mRemotePeers, &aPeer, gsUdpRemotePeerCompare, 0, 0);
	if (index == NOT_FOUND)
	{
		*thePeerState = GS_UDP_PEER_CLOSED;
		return GS_UDP_NO_ERROR;
	}
	
	aPeerFound = (GSUdpRemotePeer *)ArrayNth(aUdp->mRemotePeers, index);

	*thePeerState = (GSUdpPeerState)gt2GetConnectionState(aPeerFound->mConnection);
	return GS_UDP_NO_ERROR;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:36,代码来源:gsUdpEngine.c


示例4: wsLoginCertReadXML

gsi_bool wsLoginCertReadXML(GSLoginCertificate * cert, GSXmlStreamReader reader)
{
	char hexstr[GS_CRYPT_RSA_BYTE_SIZE*2 +1]; // temp storage for key hex strings
	int hexlen;

	GS_ASSERT(cert != NULL);
	GS_ASSERT(reader != NULL);

	if (gsi_is_false(gsXmlReadChildAsInt      (reader, "length",     (int*)&cert->mLength))      ||
		gsi_is_false(gsXmlReadChildAsInt      (reader, "version",    (int*)&cert->mVersion))     ||
		gsi_is_false(gsXmlReadChildAsInt      (reader, "partnercode",(int*)&cert->mPartnerCode)) ||
		gsi_is_false(gsXmlReadChildAsInt      (reader, "namespaceid",(int*)&cert->mNamespaceId)) ||
		gsi_is_false(gsXmlReadChildAsInt      (reader, "userid",     (int*)&cert->mUserId))      ||
		gsi_is_false(gsXmlReadChildAsInt      (reader, "profileid",  (int*)&cert->mProfileId))   ||
		gsi_is_false(gsXmlReadChildAsInt      (reader, "expiretime", (int*)&cert->mExpireTime))  ||
		gsi_is_false(gsXmlReadChildAsTStringNT (reader, "profilenick", cert->mProfileNick, WS_LOGIN_NICK_LEN))       ||
		gsi_is_false(gsXmlReadChildAsTStringNT (reader, "uniquenick",  cert->mUniqueNick,  WS_LOGIN_UNIQUENICK_LEN)) ||
		gsi_is_false(gsXmlReadChildAsTStringNT (reader, "cdkeyhash",   cert->mCdKeyHash,   WS_LOGIN_KEYHASH_LEN))    ||

		gsi_is_false(gsXmlReadChildAsStringNT (reader, "peerkeymodulus", hexstr, GS_CRYPT_RSA_BYTE_SIZE*2 +1)) ||
		gsi_is_false(gsLargeIntSetFromHexString(&cert->mPeerPublicKey.modulus, hexstr)) ||

		gsi_is_false(gsXmlReadChildAsStringNT (reader, "peerkeyexponent", hexstr, GS_CRYPT_RSA_BYTE_SIZE*2 +1)) ||
		gsi_is_false(gsLargeIntSetFromHexString(&cert->mPeerPublicKey.exponent, hexstr)) ||

		gsi_is_false(gsXmlReadChildAsHexBinary(reader, "serverdata", cert->mServerData, WS_LOGIN_SERVERDATA_LEN, &hexlen)) ||

		gsi_is_false(gsXmlReadChildAsHexBinary(reader, "signature", cert->mSignature, WS_LOGIN_SIGNATURE_LEN, &hexlen))
		)
	{
		return gsi_false;
	}
	return gsi_true;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:34,代码来源:AuthService.c


示例5: gsUdpEngineRemoveMsgHandler

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// UDP Layer must be initialized
// When a message handler is done or shutting down, the message handler should remove
// itself from the UDP Layer
// The header cannot be empty
GSUdpErrorCode gsUdpEngineRemoveMsgHandler(char theHeader[GS_UDP_MSG_HEADER_LEN])
{
	GSUdpEngineObject *aUdp = gsUdpEngineGetEngine();
	GSUdpMsgHandler aHandler;
	int index;
	
	GS_ASSERT(aUdp->mInitialized);
	GS_ASSERT(theHeader);
	if (!aUdp->mInitialized)
	{
		gsDebugFormat(GSIDebugCat_Common, GSIDebugType_Network, GSIDebugLevel_Debug,
			"[Udp Engine] Engine not initialized\n");
		return GS_UDP_NETWORK_ERROR;
	}

	if (!theHeader || !theHeader[0])
	{
		gsDebugFormat(GSIDebugCat_Common, GSIDebugType_Network, GSIDebugLevel_Debug,
			"[Udp Engine] invalid or empty header\n");
		return GS_UDP_PARAMETER_ERROR;
	}
	
	memcpy(aHandler.mHeader, theHeader, GS_UDP_MSG_HEADER_LEN);

	index = ArraySearch(aUdp->mMsgHandlers, &aHandler, gsUdpMsgHandlerCompare2, 0, 0);
	if (index != NOT_FOUND)
	{
		ArrayDeleteAt(aUdp->mMsgHandlers, index);
	}
	return GS_UDP_NO_ERROR;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:37,代码来源:gsUdpEngine.c


示例6: add_definition

    bool add_definition(const char* original, const char* replacement)
    {
        int cmp = strcmp(original, replacement);

        GS_ASSERT(original[0] != '\0');
        GS_ASSERT(replacement[0] != '\0');
        GS_ASSERT(this->size < this->max);
        GS_ASSERT(cmp != 0);

        if (original[0] == '\0') return false;
        if (replacement[0] == '\0') return false;
        if (this->size >= this->max) return false;
        if (cmp == 0) return false;

        // make sure the original name is not duplicated
        for (size_t i=0; i<this->size; i++)
        {
            size_t index = this->get_index(i);
            int cmp = strcmp(original, &this->originals[index]);
            GS_ASSERT(cmp != 0);
            if (cmp == 0) return false;
        }

        size_t index = this->get_index(this->size);
        strncpy(&this->originals[index], original, this->name_max);
        this->originals[index + this->name_max] = '\0';
        strncpy(&this->replacements[index], replacement, this->name_max);
        this->replacements[index + this->name_max] = '\0';
        this->size++;

        return true;
    }
开发者ID:Dzshiftt,项目名称:Gnomescroll,代码行数:32,代码来源:name_map.hpp


示例7: wsLoginCertWriteXML

gsi_bool wsLoginCertWriteXML(const GSLoginCertificate * cert, const char * aNamespace, GSXmlStreamWriter writer)
{
	GS_ASSERT(cert != NULL);
	GS_ASSERT(writer != NULL);

	if (gsi_is_false(gsXmlWriteIntElement(writer, aNamespace, "length",      cert->mLength))       ||
		gsi_is_false(gsXmlWriteIntElement(writer, aNamespace, "version",     cert->mVersion))      ||
		gsi_is_false(gsXmlWriteIntElement(writer, aNamespace, "partnercode", cert->mPartnerCode))  ||
		gsi_is_false(gsXmlWriteIntElement(writer, aNamespace, "namespaceid", cert->mNamespaceId))  ||
		gsi_is_false(gsXmlWriteIntElement(writer, aNamespace, "userid",      cert->mUserId))       ||
		gsi_is_false(gsXmlWriteIntElement(writer, aNamespace, "profileid",   cert->mProfileId))    ||
		gsi_is_false(gsXmlWriteIntElement(writer, aNamespace, "expiretime",  cert->mExpireTime))   ||
		gsi_is_false(gsXmlWriteAsciiStringElement(writer, aNamespace, "profilenick", cert->mProfileNick))||
		gsi_is_false(gsXmlWriteAsciiStringElement(writer, aNamespace, "uniquenick",  cert->mUniqueNick)) ||
		gsi_is_false(gsXmlWriteAsciiStringElement(writer, aNamespace, "cdkeyhash",   cert->mCdKeyHash))  ||
		gsi_is_false(gsXmlWriteLargeIntElement(writer, aNamespace, "peerkeymodulus", &cert->mPeerPublicKey.modulus)) ||
 		gsi_is_false(gsXmlWriteLargeIntElement(writer, aNamespace, "peerkeyexponent", &cert->mPeerPublicKey.exponent)) ||	
		gsi_is_false(gsXmlWriteHexBinaryElement(writer, aNamespace, "serverdata", cert->mServerData, WS_LOGIN_SERVERDATA_LEN)) ||
		gsi_is_false(gsXmlWriteHexBinaryElement(writer, aNamespace, "signature", cert->mSignature, WS_LOGIN_SIGNATURE_LEN))
		)
	{
		//gsLargeIntReverseBytes(&cert->mPeerPublicKey.modulus);
		//gsLargeIntReverseBytes(&cert->mPeerPublicKey.exponent);
		return gsi_false;
	}
		
	//gsLargeIntReverseBytes(&cert->mPeerPublicKey.modulus);
	//gsLargeIntReverseBytes(&cert->mPeerPublicKey.exponent);
	return gsi_true;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:30,代码来源:AuthService.c


示例8: sciInterfaceCreate

SCResult sciInterfaceCreate(SCInterface** theInterfaceOut)
{
#ifdef GSI_SC_STATIC_MEM
	static SCInterface gStaticInterface;
#endif

	GS_ASSERT(theInterfaceOut != NULL);

	// Check to see if the availability check has been performed and if it has
	// set the service URL prepended with the gamename
	if (__GSIACResult == GSIACAvailable)
	{
		if (scServiceURL[0] == '\0')
			snprintf(scServiceURL, SC_SERVICE_MAX_URL_LEN, SC_SERVICE_URL_FORMAT, __GSIACGamename);
	}
	else
		return SCResult_NO_AVAILABILITY_CHECK;	

#ifdef GSI_SC_STATIC_MEM
	*theInterfaceOut = &gStaticInterface;
#else
	*theInterfaceOut = (SCInterface*)gsimalloc(sizeof(SCInterface));
	if (*theInterfaceOut == NULL)
	{
		return SCResult_OUT_OF_MEMORY;
	}
#endif

	GS_ASSERT(*theInterfaceOut != NULL);
	memset(*theInterfaceOut, 0, sizeof(SCInterface));
	return SCResult_NO_ERROR;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:32,代码来源:sciInterface.c


示例9: parse_block

size_t parse_block(bool (*process_token) (const char*, const char*, Data*), const char* terminator, const char* str, Data* data)
{
    data->reset();
    data->valid = false;
    const size_t LONGEST_LINE = 0x7F;
    static char buf[LONGEST_LINE+1] = {'\0'};
    size_t i = 0;
    while (1)
    {
        char c = '\0';
        size_t n = 0;
        while ((c = str[i++]) != '\0' && c != '\n' && n < LONGEST_LINE)
            buf[n++] = c;
        buf[n] = '\0';
        GS_ASSERT(c == '\n');
        if (c != '\n') return i;
        if (strcmp(buf, terminator) == 0) break;

        GS_ASSERT(n > TAG_LENGTH + TAG_DELIMITER_LENGTH);
        if (n <= TAG_LENGTH + TAG_DELIMITER_LENGTH) return i;
        GS_ASSERT(buf[TAG_LENGTH] == TAG_DELIMITER[0]);
        if (buf[TAG_LENGTH] != TAG_DELIMITER[0]) return i;
        buf[TAG_LENGTH] = '\0';

        const char* key = &buf[0];
        const char* token = &buf[TAG_LENGTH+1];

        if (!process_token(key, token, data)) return i;
    }
    data->valid = true;
    return i;
}
开发者ID:Dzshiftt,项目名称:Gnomescroll,代码行数:32,代码来源:parse.hpp


示例10: ArrayGrow

/* ArrayGrow
 * Reallocates the array to a new size, incresed by growby
 */
static void ArrayGrow(DArray array)
{
	GS_ASSERT(array->elemsize)	// sanity check -mj Oct 31st
	array->capacity +=  array->growby;
	array->list = gsirealloc(array->list, (size_t) array->capacity * array->elemsize);
	GS_ASSERT(array->list);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:10,代码来源:darray.c


示例11: printf

void map_chunk_uncompressed_StoC::handle(char* buff, size_t byte_num)
{
    //printf("map_chunk: alias= %d for %d %d \n", chunk_alias, chunk_index%MAP_CHUNK_XDIM, chunk_index /MAP_CHUNK_XDIM);
    //printf("byte_size= %d \n", byte_size);
#if MAP_NET_DEBUG
    printf("map chunk is %d bytes \n", byte_size);
#endif
    GS_ASSERT(client_chunk_alias_list[chunk_alias] == -1);
    client_chunk_alias_list[chunk_alias] = chunk_index;

    int cx = chunk_index % MAP_CHUNK_XDIM;
    int cy = chunk_index / MAP_CHUNK_XDIM;

    GS_ASSERT(main_map->chunk[chunk_index] == NULL);
    main_map->load_chunk(cx, cy);
    class MapChunk* m = main_map->chunk[chunk_index];

/*
    This is evil, dont do this
*/

    memcpy((char *) m->e, buff, byte_num);
    m->refresh_height_cache(); //refesh height cache after memcpy

    main_map->chunk_received(cx,cy);
}
开发者ID:Dzshiftt,项目名称:Gnomescroll,代码行数:26,代码来源:t_StoC.cpp


示例12: gpiGetPeerByAddr

// NOTE: use this function only when in a UDP layer callback
GPIPeer * gpiGetPeerByAddr(const GPConnection *connection,
                           unsigned int ip,
                           unsigned short port)
{
	GPIConnection * iconnection = (GPIConnection*)*connection;
	GPIPeer * pcurr;

	GS_ASSERT(ip);
	GS_ASSERT(port);
	if (!ip && !port)
		return NULL;
	// Go through the list of peers.
	////////////////////////////////
	for(pcurr = iconnection->peerList ; pcurr != NULL ; pcurr  = pcurr->pnext)
	{
		// Check for a match.
		/////////////////////
		if(pcurr->ip == ip && pcurr->port == port)
		{
			// Got it.
			//////////
			return pcurr;
		}
	}

	return NULL;
}
开发者ID:DevSlashNull,项目名称:GameSpy,代码行数:28,代码来源:gpiPeer.c


示例13: gpiPeerAddOp

// gpiPeerAddOp notes:
// Assumes non-null inputs!
// The queue should be empty when the first element is added.
// Any new element added will be added to the end of the queue.
void gpiPeerAddOp(GPIPeer *peer, GPIPeerOp *operation)
{
	GS_ASSERT(peer);
	GS_ASSERT(operation);

	if (!peer || !operation)
	{
		gsDebugFormat(GSIDebugCat_GP, GSIDebugType_Misc, GSIDebugLevel_WarmError, "Peer operation not added");
		return;
	}
	// Three cases can occur:
	// The list is empty - set all pointers to the new node
	// The list has only one element - set the first element's next to the new 
	//     and set the last element to the new
	// The list has more than one element - add the new element to the end of 
	//     the queue
	if (peer->peerOpQueue.opList == NULL)
	{
		peer->peerOpQueue.first = operation;
		peer->peerOpQueue.last = operation;
		peer->peerOpQueue.opList = operation;		
	}
	else if (peer->peerOpQueue.first == peer->peerOpQueue.last)
	{
		peer->peerOpQueue.first->next = operation;
		peer->peerOpQueue.last = operation;
	}
	else
	{
		peer->peerOpQueue.last->next = operation;
		peer->peerOpQueue.last = operation;		
	}

	gsDebugFormat(GSIDebugCat_GP, GSIDebugType_Misc, GSIDebugLevel_Notice, "Peer Operation Added");
}
开发者ID:DevSlashNull,项目名称:GameSpy,代码行数:39,代码来源:gpiPeer.c


示例14: OnRomClose

GS_VOID CPokeMiniEmulatorDlg::OnRomOpen()
{
    OnRomClose();

    {
        CFileDialog fileDialog(TRUE, _T("*.min"), NULL, OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_EXPLORER, _T("pokemon mini rom(*.min)|*.min"));
        if (IDOK == fileDialog.DoModal())
        {
            CString fileName = fileDialog.GetPathName();
            FILE *pFile = _wfopen(fileName, L"rb");
            fseek(pFile, 0, SEEK_END);
            m_romSize = ftell(pFile);
            m_pRomData = GS_MALLOCZ_OBJ_N(GS_BYTE, m_romSize);
            fseek(pFile, 0, SEEK_SET);
            fread(m_pRomData, 1, m_romSize, pFile);
            fclose(pFile);

            m_pSaveData = GS_MALLOCZ_OBJ_N(GS_BYTE, m_pSystem->SaveSize());
        }
    }

    if (m_pSystem->Initialize(m_pRomData, m_romSize, m_pSaveData))
    {
        HRESULT hr = S_OK;
        hr = m_pDirectSoundBuffer->SetCurrentPosition(0);
        GS_ASSERT(SUCCEEDED(hr));
        hr = m_pDirectSoundBuffer->Play(0, 0, DSBPLAY_LOOPING);
        GS_ASSERT(SUCCEEDED(hr));

        m_state = EMU_RUN;
        m_emuThread = CreateThread(NULL, 0, EmuThread, this, 0, &m_emuThreadID);
    }
}
开发者ID:DragonNeos,项目名称:pokemon-mini-emulator,代码行数:33,代码来源:PokeMiniEmulatorDlg.cpp


示例15: gsUdpEngineRejectPeer

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// UDP Layer must be initialized
// theIp and thePort cannot be 0 (Zero)
// Rejects a Peer's request for communication 
// Should only be used by App
GSUdpErrorCode gsUdpEngineRejectPeer(unsigned int theIp, unsigned short thePort)
{
	GSUdpRemotePeer aRemotePeer;	
	GSUdpEngineObject *aUdp = gsUdpEngineGetEngine();
	int index;
	GS_ASSERT(aUdp->mInitialized);
	GS_ASSERT(theIp);
	GS_ASSERT(thePort);
	if (!aUdp->mInitialized)
	{
		gsDebugFormat(GSIDebugCat_Common, GSIDebugType_Network, GSIDebugLevel_Debug,
			"[Udp Engine] Engine not initialized\n");
		return GS_UDP_NETWORK_ERROR;
	}

	if (theIp == 0 || thePort == 0)
	{
		gsDebugFormat(GSIDebugCat_Common, GSIDebugType_Network, GSIDebugLevel_Debug,
			"[Udp Engine] Invalid parameter(s), check ip, port\n");
		return GS_UDP_PARAMETER_ERROR;
	}

	// Find the connection to reject in our array of peers
	aRemotePeer.mAddr = theIp;
	aRemotePeer.mPort = thePort;
	index = ArraySearch(aUdp->mRemotePeers, &aRemotePeer, gsUdpRemotePeerCompare, 0, 0);
	if (index != NOT_FOUND)
	{
		GSUdpRemotePeer *aPeerFound = (GSUdpRemotePeer *)ArrayNth(aUdp->mRemotePeers, index);
		gt2Reject(aPeerFound->mConnection, NULL, 0);
		ArrayDeleteAt(aUdp->mRemotePeers, index);
	}
	return GS_UDP_NO_ERROR;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:40,代码来源:gsUdpEngine.c


示例16: SetElement

/* SetElement
 * Sets the element at pos to the contents of elem
 */
static void SetElement(DArray array, const void *elem, int pos)
{
	GS_ASSERT(array)			// safety check -mj Oct 31st
	GS_ASSERT(elem)	
	GS_ASSERT(array->elemsize)	

	memcpy(ArrayNth(array,pos), elem, (size_t)array->elemsize);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:11,代码来源:darray.c


示例17: init_equipment_texture

static void init_equipment_texture()
{
    GLuint min_filter = GL_LINEAR;
    GLuint mag_filter = GL_NEAREST;
    int ret = create_texture_from_file(MEDIA_PATH "sprites/container/equipment48.png", &EquipmentTexture, min_filter, mag_filter);
    GS_ASSERT(ret == 0);
    GS_ASSERT(EquipmentTexture != 0);
}
开发者ID:Dzshiftt,项目名称:Gnomescroll,代码行数:8,代码来源:texture.cpp


示例18: init_crusher_texture

static void init_crusher_texture()
{
    GLuint min_filter = GL_LINEAR;
    GLuint mag_filter = GL_NEAREST;
    int ret = create_texture_from_file(MEDIA_PATH "sprites/container/crusher48.png", &CrusherTexture, min_filter, mag_filter);
    GS_ASSERT(ret == 0);
    GS_ASSERT(CrusherTexture != 0);
}
开发者ID:Dzshiftt,项目名称:Gnomescroll,代码行数:8,代码来源:texture.cpp


示例19: init_storage_block_texture

static void init_storage_block_texture()
{
    GLuint min_filter = GL_LINEAR;
    GLuint mag_filter = GL_NEAREST;
    int ret = create_texture_from_file(MEDIA_PATH "sprites/container/storage_block48.png", &StorageBlockTexture, min_filter, mag_filter);
    GS_ASSERT(ret == 0);
    GS_ASSERT(StorageBlockTexture != 0);
}
开发者ID:Dzshiftt,项目名称:Gnomescroll,代码行数:8,代码来源:texture.cpp


示例20: save_active_names

bool save_active_names(const Property* properties, size_t count, size_t name_len, const char* filename)
{
    bool worked = false;

    const char tmp[] = ".tmp";
    char* tmp_filename = (char*)malloc((strlen(filename) + sizeof(tmp)) * sizeof(char));
    sprintf(tmp_filename, "%s%s", filename, tmp);

    const char bak[] = ".bak";
    char* bak_filename = (char*)malloc((strlen(filename) + sizeof(bak)) * sizeof(char));
    sprintf(bak_filename, "%s%s", filename, bak);

    char* buf = (char*)malloc((name_len+2) * sizeof(char));

    FILE* f = fopen(tmp_filename, "w");
    GS_ASSERT(f != NULL);
    if (f == NULL)
        goto error;

    for (size_t i=0; i<count; i++)
    {
        if (!properties[i].loaded) continue;
        size_t len = strlen(properties[i].name);
        GS_ASSERT(len > 0 && len <= name_len);
        if (len <= 0 || len > name_len)
            goto error;
        strncpy(buf, properties[i].name, len);
        buf[len] = '\n';
        buf[len+1] = '\0';
        size_t wrote = fwrite(buf, sizeof(char), len+1, f);
        GS_ASSERT(wrote == len + 1);
        if (wrote != len + 1)
            goto error;
    }

    worked = true;

    error:  // ERROR LABEL

    if (f != NULL)
    {
        worked = (fclose(f) == 0);
        GS_ASSERT(worked);
    }

    if (worked)
    {
        worked = save_tmp_file(filename, tmp_filename, bak_filename);
        GS_ASSERT(worked);
    }

    free(tmp_filename);
    free(bak_filename);
    free(buf);

    return worked;
}
开发者ID:Dzshiftt,项目名称:Gnomescroll,代码行数:57,代码来源:name_map.hpp



注:本文中的GS_ASSERT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GS_L函数代码示例发布时间:2022-05-30
下一篇:
C++ GSVector4函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap