本文整理汇总了C++中GS_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ GS_ASSERT函数的具体用法?C++ GS_ASSERT怎么用?C++ GS_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GS_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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");
}
示例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);
}
}
示例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;
}