rename assert2 debug_assert; use instead of all plain assert(), since there are no longer any issues (e.g. can't use while handling an exception)
This was SVN commit r2447.
This commit is contained in:
parent
cf37e9cbe6
commit
ec6b78b252
@ -314,7 +314,7 @@ void CXMLReader::Init(const CStr& xml_filename)
|
||||
#undef EL
|
||||
|
||||
XMBElement root = xmb_file.getRoot();
|
||||
assert(root.getNodeName() == el_scenario);
|
||||
debug_assert(root.getNodeName() == el_scenario);
|
||||
nodes = root.getChildNodes();
|
||||
|
||||
// find out total number of entities+nonentities
|
||||
@ -379,7 +379,7 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
|
||||
// wrapped, since we only yield after a complete iteration.
|
||||
|
||||
XMBElement entity = entities.item(entity_idx++);
|
||||
assert(entity.getNodeName() == el_entity);
|
||||
debug_assert(entity.getNodeName() == el_entity);
|
||||
|
||||
CStrW TemplateName;
|
||||
int PlayerID;
|
||||
@ -443,7 +443,7 @@ int CXMLReader::ReadNonEntities(XMBElement parent, double end_time)
|
||||
// wrapped, since we only yield after a complete iteration.
|
||||
|
||||
XMBElement nonentity = nonentities.item(nonentity_idx++);
|
||||
assert(nonentity.getNodeName() == el_nonentity);
|
||||
debug_assert(nonentity.getNodeName() == el_nonentity);
|
||||
|
||||
CStr ActorName;
|
||||
CVector3D Position;
|
||||
|
@ -119,7 +119,7 @@ SMaterialColor CMaterial::GetEmissive()
|
||||
|
||||
SMaterialColor CMaterial::GetPlayerColor()
|
||||
{
|
||||
assert(m_PlayerID != PLAYER_NONE);
|
||||
debug_assert(m_PlayerID != PLAYER_NONE);
|
||||
// because this should never be called unless IsPlayer returned true
|
||||
|
||||
if (m_PlayerID == PLAYER_OTHER /* TODO: or if player-colour is globally disabled */ )
|
||||
|
@ -111,7 +111,7 @@ static CVector3D SkinPoint(const CVector3D& pos,const SVertexBlend& blend,
|
||||
CVector3D result,tmp;
|
||||
|
||||
// must have at least one valid bone if we're using SkinPoint
|
||||
assert(blend.m_Bone[0]!=0xff);
|
||||
debug_assert(blend.m_Bone[0]!=0xff);
|
||||
|
||||
const CMatrix3D& m=bonestates[blend.m_Bone[0]];
|
||||
m.Transform(pos,result);
|
||||
@ -137,7 +137,7 @@ void CModel::CalcBounds()
|
||||
{
|
||||
if (m_Anim->m_ObjectBounds.IsEmpty())
|
||||
CalcAnimatedObjectBound(m_Anim->m_AnimDef, m_Anim->m_ObjectBounds);
|
||||
assert(! m_Anim->m_ObjectBounds.IsEmpty()); // (if this happens, it'll be recalculating the bounds every time)
|
||||
debug_assert(! m_Anim->m_ObjectBounds.IsEmpty()); // (if this happens, it'll be recalculating the bounds every time)
|
||||
m_ObjectBounds = m_Anim->m_ObjectBounds;
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ void CModel::GenerateBoneMatrices()
|
||||
|
||||
PROFILE( "generating bone matrices" );
|
||||
|
||||
assert(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys());
|
||||
debug_assert(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys());
|
||||
|
||||
m_Anim->m_AnimDef->BuildBoneMatrices(m_AnimTime,m_BoneMatrices);
|
||||
|
||||
|
@ -348,7 +348,7 @@ void CObjectBase::CalculateVariation(std::set<CStr>& strings, variation_key& cho
|
||||
std::vector<u8> matches;
|
||||
typedef std::vector<u8>::const_iterator Iter;
|
||||
|
||||
assert(grp->size() < 256); // else they won't fit in the vector
|
||||
debug_assert(grp->size() < 256); // else they won't fit in the vector
|
||||
|
||||
for (uint i = 0; i < grp->size(); ++i)
|
||||
if (strings.count((*grp)[i].m_VariantName))
|
||||
@ -387,7 +387,7 @@ void CObjectBase::CalculateVariation(std::set<CStr>& strings, variation_key& cho
|
||||
// since actors are meant to have purely visual manifestations.)
|
||||
int randNum = (int)( ((float)rand() / RAND_MAX) * totalFreq );
|
||||
|
||||
assert(randNum < totalFreq);
|
||||
debug_assert(randNum < totalFreq);
|
||||
|
||||
// and use that to choose one of the variants
|
||||
for (Iter it = matches.begin(); it != matches.end(); ++it)
|
||||
@ -400,12 +400,12 @@ void CObjectBase::CalculateVariation(std::set<CStr>& strings, variation_key& cho
|
||||
}
|
||||
}
|
||||
|
||||
assert(randNum < 0);
|
||||
debug_assert(randNum < 0);
|
||||
// This should always happen; otherwise it
|
||||
// wouldn't have chosen any of the variants.
|
||||
}
|
||||
|
||||
assert(choices.size() == m_Variants.size());
|
||||
debug_assert(choices.size() == m_Variants.size());
|
||||
|
||||
|
||||
// Also, make choices for all props:
|
||||
|
@ -152,7 +152,7 @@ void CObjectManager::AddObjectType(const char* name)
|
||||
|
||||
void CObjectManager::AddObject(ObjectKey& key, CObjectEntry* entry, int type)
|
||||
{
|
||||
assert((uint)type<m_ObjectTypes.size());
|
||||
debug_assert((uint)type<m_ObjectTypes.size());
|
||||
m_ObjectTypes[type].m_Objects.insert(std::make_pair(key, entry));
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "Particle.h"
|
||||
#include "timer.h"
|
||||
#include "ogl.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
CParticle::CParticle() :
|
||||
m_duration(0.0f),
|
||||
@ -64,7 +64,7 @@ void CParticle::Frame()
|
||||
|
||||
void CParticle::Render()
|
||||
{
|
||||
assert(m_sprite);
|
||||
debug_assert(m_sprite);
|
||||
|
||||
m_sprite->SetColour(m_colour);
|
||||
m_sprite->SetTranslation(m_position);
|
||||
|
@ -9,7 +9,7 @@
|
||||
#ifndef _RENDERABLEOBJECT_H
|
||||
#define _RENDERABLEOBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "Bound.h"
|
||||
#include "Matrix3D.h"
|
||||
|
||||
@ -87,9 +87,9 @@ public:
|
||||
// set the object renderdata
|
||||
// TODO,RC 10/04/04 - need to delete existing renderdata here, or can we
|
||||
// assume the renderer won't set renderdata when an object already has it?
|
||||
// - just assert we've no renderdata at the minute
|
||||
// - just debug_assert we've no renderdata at the minute
|
||||
void SetRenderData(CRenderData* renderdata) {
|
||||
assert(m_RenderData==0);
|
||||
debug_assert(m_RenderData==0);
|
||||
m_RenderData=renderdata;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ float CTerrain::getExactGroundLevel( float x, float y ) const
|
||||
yi = m_MapSize - 1; yf = 1.0f;
|
||||
}
|
||||
/*
|
||||
assert( isOnMap( x, y ) );
|
||||
debug_assert( isOnMap( x, y ) );
|
||||
|
||||
if( !isOnMap( x, y ) )
|
||||
return 0.0f;
|
||||
|
@ -153,7 +153,7 @@ void CTextureEntry::LoadTexture()
|
||||
{
|
||||
if (m_TexturePath.size() == 0)
|
||||
{
|
||||
assert(m_pParent);
|
||||
debug_assert(m_pParent);
|
||||
m_pParent->LoadTexture();
|
||||
m_Handle = m_pParent->m_Handle;
|
||||
return;
|
||||
@ -184,7 +184,7 @@ void CTextureEntry::BuildBaseColor()
|
||||
// cases c&d: We don't have our own texture, use parent base color instead
|
||||
if (m_TexturePath.size() == 0)
|
||||
{
|
||||
assert(m_pParent);
|
||||
debug_assert(m_pParent);
|
||||
m_BaseColor=m_pParent->GetBaseColor();
|
||||
m_BaseColorValid=true;
|
||||
return;
|
||||
|
@ -121,7 +121,7 @@ void CTextureManager::LoadTerrainsFromXML(const char *filename)
|
||||
|
||||
/*CTextureEntry* CTextureManager::AddTexture(const char* filename,int type)
|
||||
{
|
||||
assert((uint)type<m_TerrainTextures.size());
|
||||
debug_assert((uint)type<m_TerrainTextures.size());
|
||||
|
||||
// create new texture entry
|
||||
CTextureEntry* texentry=new CTextureEntry(filename,type);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _UNIT_H
|
||||
#define _UNIT_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
class CModel;
|
||||
class CObjectEntry;
|
||||
@ -16,10 +16,10 @@ class CUnit
|
||||
public:
|
||||
// constructor - unit invalid without a model and object
|
||||
CUnit(CObjectEntry* object, CModel* model) : m_Object(object), m_Model(model), m_Entity(NULL) {
|
||||
assert(object && model);
|
||||
debug_assert(object && model);
|
||||
}
|
||||
CUnit(CObjectEntry* object, CModel* model, CEntity* entity) : m_Object(object), m_Model(model), m_Entity(entity) {
|
||||
assert(object && model);
|
||||
debug_assert(object && model);
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
@ -202,7 +202,7 @@ JSBool JSI_Camera::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* v
|
||||
|
||||
JSBool JSI_Camera::lookAt( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 2 );
|
||||
debug_assert( argc >= 2 );
|
||||
|
||||
JSI_Vector3D::Vector3D_Info* v = NULL;
|
||||
Camera_Info* cameraInfo = (Camera_Info*)JS_GetPrivate( cx, obj );
|
||||
|
@ -47,7 +47,7 @@ void CButton::SetupText()
|
||||
if (!GetGUI())
|
||||
return;
|
||||
|
||||
assert(m_GeneratedTexts.size()>=1);
|
||||
debug_assert(m_GeneratedTexts.size()>=1);
|
||||
|
||||
CStr font;
|
||||
if (GUI<CStr>::GetSetting(this, "font", font) != PS_OK || font.Length()==0)
|
||||
|
@ -62,7 +62,7 @@ void CCheckBox::SetupText()
|
||||
if (!GetGUI())
|
||||
return;
|
||||
|
||||
assert(m_GeneratedTexts.size()>=1);
|
||||
debug_assert(m_GeneratedTexts.size()>=1);
|
||||
|
||||
CStr font;
|
||||
CGUIString caption;
|
||||
|
@ -7,7 +7,7 @@ gee@pyro.nu
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "lib/res/unifont.h"
|
||||
@ -292,7 +292,7 @@ CGUI::CGUI() : m_InternalNameNumber(0), m_MouseButtons(0), m_FocusedObject(NULL)
|
||||
|
||||
// Construct the parent object for all GUI JavaScript things
|
||||
m_ScriptObject = JS_NewObject(g_ScriptingHost.getContext(), &GUIClass, NULL, NULL);
|
||||
assert(m_ScriptObject != NULL); // How should it handle errors?
|
||||
debug_assert(m_ScriptObject != NULL); // How should it handle errors?
|
||||
JS_AddRoot(g_ScriptingHost.getContext(), &m_ScriptObject);
|
||||
|
||||
// This will make this invisible, not add
|
||||
@ -346,7 +346,7 @@ void CGUI::Process()
|
||||
/*
|
||||
|
||||
// TODO Gee: check if m_pInput is valid, otherwise return
|
||||
/// assert(m_pInput);
|
||||
/// debug_assert(m_pInput);
|
||||
|
||||
// Pre-process all objects
|
||||
try
|
||||
@ -1096,7 +1096,7 @@ void CGUI::Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile)
|
||||
|
||||
void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent)
|
||||
{
|
||||
assert(pParent);
|
||||
debug_assert(pParent);
|
||||
int i;
|
||||
|
||||
// Our object we are going to create
|
||||
@ -1399,7 +1399,7 @@ void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile)
|
||||
}
|
||||
else if (ElementName == "effect")
|
||||
{
|
||||
assert(! effects); // DTD should only allow one effect per sprite
|
||||
debug_assert(! effects); // DTD should only allow one effect per sprite
|
||||
effects = new SGUIImageEffects;
|
||||
Xeromyces_ReadEffects(child, pFile, *effects);
|
||||
}
|
||||
@ -1534,7 +1534,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite
|
||||
CStr ElementName (pFile->getElementString(child.getNodeName()));
|
||||
if (ElementName == "effect")
|
||||
{
|
||||
assert(! image.m_Effects); // DTD should only allow one effect per sprite
|
||||
debug_assert(! image.m_Effects); // DTD should only allow one effect per sprite
|
||||
image.m_Effects = new SGUIImageEffects;
|
||||
Xeromyces_ReadEffects(child, pFile, *image.m_Effects);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ CInput::~CInput()
|
||||
|
||||
int CInput::ManuallyHandleEvent(const SDL_Event* ev)
|
||||
{
|
||||
assert(m_iBufferPos != -1);
|
||||
debug_assert(m_iBufferPos != -1);
|
||||
|
||||
// Since the GUI framework doesn't handle to set settings
|
||||
// in Unicode (CStrW), we'll simply retrieve the actual
|
||||
@ -1017,7 +1017,7 @@ void CInput::UpdateText(int from, int to_before, int to_after)
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(to_before != -1);
|
||||
debug_assert(to_before != -1);
|
||||
|
||||
list<SRow>::iterator destroy_row_from, destroy_row_to;
|
||||
// Used to check if the above has been set to anything,
|
||||
|
@ -57,7 +57,7 @@ void CList::SetupText()
|
||||
|
||||
//LOG(ERROR, LOG_CATEGORY, "SetupText() %s", GetPresentableName().c_str());
|
||||
|
||||
//assert(m_GeneratedTexts.size()>=1);
|
||||
//debug_assert(m_GeneratedTexts.size()>=1);
|
||||
|
||||
m_ItemsYPositions.resize( pList->m_Items.size()+1 );
|
||||
|
||||
@ -327,7 +327,7 @@ void CList::DrawList(const int &selected,
|
||||
|
||||
if (selected != -1)
|
||||
{
|
||||
assert(selected >= 0 && selected+1 < (int)m_ItemsYPositions.size());
|
||||
debug_assert(selected >= 0 && selected+1 < (int)m_ItemsYPositions.size());
|
||||
|
||||
// Get rectangle of selection:
|
||||
CRect rect(rect.left, rect.top + m_ItemsYPositions[selected] - scroll,
|
||||
|
@ -55,7 +55,7 @@ void CText::SetupText()
|
||||
if (!GetGUI())
|
||||
return;
|
||||
|
||||
assert(m_GeneratedTexts.size()>=1);
|
||||
debug_assert(m_GeneratedTexts.size()>=1);
|
||||
|
||||
CStr font;
|
||||
if (GUI<CStr>::GetSetting(this, "font", font) != PS_OK || font.Length()==0)
|
||||
|
@ -45,7 +45,7 @@ void CTooltip::SetupText()
|
||||
if (!GetGUI())
|
||||
return;
|
||||
|
||||
assert(m_GeneratedTexts.size()==1);
|
||||
debug_assert(m_GeneratedTexts.size()==1);
|
||||
|
||||
CStr font;
|
||||
if (GUI<CStr>::GetSetting(this, "font", font) != PS_OK || font.Length()==0)
|
||||
|
@ -353,7 +353,7 @@ void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, CStr &SpriteName, CRect
|
||||
Sprites[SpriteName] = Sprite;
|
||||
|
||||
it = Sprites.find(SpriteName);
|
||||
assert(it != Sprites.end()); // The insertion above shouldn't fail
|
||||
debug_assert(it != Sprites.end()); // The insertion above shouldn't fail
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ static bool GetTooltip(IGUIObject* obj, CStr &style)
|
||||
|
||||
void ShowTooltip(IGUIObject* obj, CPos pos, CStr& style, CGUI* gui)
|
||||
{
|
||||
assert(obj);
|
||||
debug_assert(obj);
|
||||
|
||||
// Get the object referenced by 'tooltip_style'
|
||||
IGUIObject* tooltipobj = gui->FindObjectByName("__tooltip_"+style);
|
||||
|
@ -60,7 +60,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback,
|
||||
if (_to == _from && itTextChunk->m_From == itTextChunk->m_To)
|
||||
{
|
||||
// These should never be able to have more than one tag.
|
||||
assert(itTextChunk->m_Tags.size()==1);
|
||||
debug_assert(itTextChunk->m_Tags.size()==1);
|
||||
|
||||
// Now do second check
|
||||
// because icons and images are placed on exactly one position
|
||||
|
@ -316,7 +316,7 @@ bool CClientArea::SetClientArea(const CStr& Value)
|
||||
{
|
||||
if (valuenr!=3)
|
||||
{
|
||||
assert(valuenr <= 2);
|
||||
debug_assert(valuenr <= 2);
|
||||
arg_start[valuenr+1] = i+1;
|
||||
arg_count[valuenr] = arg_start[valuenr+1] - arg_start[valuenr] - 1;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ gee@pyro.nu
|
||||
|
||||
///// janwas: again, including etiquette?
|
||||
#include "Parser.h"
|
||||
#include <assert.h>
|
||||
|
||||
/////
|
||||
|
||||
#include "gui/scripting/JSInterface_IGUIObject.h"
|
||||
@ -87,7 +87,7 @@ IGUIObject::~IGUIObject()
|
||||
void IGUIObject::AddChild(IGUIObject *pChild)
|
||||
{
|
||||
//
|
||||
// assert(pChild);
|
||||
// debug_assert(pChild);
|
||||
|
||||
pChild->SetParent(this);
|
||||
|
||||
@ -425,7 +425,7 @@ void IGUIObject::RegisterScriptHandler(const CStr& Action, const CStr& Code, CGU
|
||||
sprintf(buf, "__eventhandler%d", x++);
|
||||
|
||||
JSFunction* func = JS_CompileFunction(g_ScriptingHost.getContext(), pGUI->m_ScriptObject, buf, paramCount, paramNames, (const char*)Code, Code.Length(), CodeName, 0);
|
||||
assert(func); // TODO: Handle errors
|
||||
debug_assert(func); // TODO: Handle errors
|
||||
if (func)
|
||||
SetScriptHandler(Action, JS_GetFunctionObject(func));
|
||||
}
|
||||
@ -452,14 +452,14 @@ void IGUIObject::ScriptEvent(const CStr& Action)
|
||||
|
||||
// PRIVATE_TO_JSVAL assumes two-byte alignment,
|
||||
// so make sure that's always true
|
||||
assert(! ((jsval)this & JSVAL_INT));
|
||||
debug_assert(! ((jsval)this & JSVAL_INT));
|
||||
|
||||
// The IGUIObject needs to be stored inside the script's object
|
||||
jsval guiObject = PRIVATE_TO_JSVAL(this);
|
||||
|
||||
// Make a 'this', allowing access to the IGUIObject
|
||||
JSObject* jsGuiObject = JS_ConstructObjectWithArguments(g_ScriptingHost.getContext(), &JSI_IGUIObject::JSI_class, NULL, m_pGUI->m_ScriptObject, 1, &guiObject);
|
||||
assert(jsGuiObject); // TODO: Handle errors
|
||||
debug_assert(jsGuiObject); // TODO: Handle errors
|
||||
|
||||
// Prevent it from being garbage-collected before it's passed into the function
|
||||
JS_AddRoot(g_ScriptingHost.getContext(), &jsGuiObject);
|
||||
@ -470,7 +470,7 @@ void IGUIObject::ScriptEvent(const CStr& Action)
|
||||
mouseParams[1] = INT_TO_JSVAL(m_pGUI->m_MousePos.y);
|
||||
mouseParams[2] = INT_TO_JSVAL(m_pGUI->m_MouseButtons);
|
||||
JSObject* mouseObj = JS_ConstructObjectWithArguments(g_ScriptingHost.getContext(), &JSI_GUIMouse::JSI_class, NULL, m_pGUI->m_ScriptObject, 3, mouseParams);
|
||||
assert(mouseObj); // TODO: Handle errors
|
||||
debug_assert(mouseObj); // TODO: Handle errors
|
||||
|
||||
// Don't garbage collect the mouse
|
||||
JS_AddRoot(g_ScriptingHost.getContext(), &mouseObj);
|
||||
|
@ -530,7 +530,7 @@ JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
assert(argc == 1);
|
||||
debug_assert(argc == 1);
|
||||
|
||||
// Store the IGUIObject in the JS object's 'private' area
|
||||
IGUIObject* guiObject = (IGUIObject*)JSVAL_TO_PRIVATE(argv[0]);
|
||||
@ -542,7 +542,7 @@ JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc
|
||||
|
||||
JSBool JSI_IGUIObject::getByName(JSContext* cx, JSObject* UNUSEDPARAM(obj), unsigned int argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
assert(argc == 1);
|
||||
debug_assert(argc == 1);
|
||||
|
||||
CStr objectName = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
|
||||
|
||||
|
@ -12,7 +12,7 @@ providing hashes and strings on request.
|
||||
|
||||
#include "StrImmutable.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
namespace I18n
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "TSComponent.h"
|
||||
#include "StringConvert.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "ps/CLogger.h"
|
||||
@ -328,7 +328,7 @@ bool CLocale::ReadCached(StringBuffer* sb, Str& str)
|
||||
return false;
|
||||
|
||||
// Check every variable to see whether they're identical
|
||||
assert(sb->Variables.size() == (*it).second.vars.size()); // this should always be true
|
||||
debug_assert(sb->Variables.size() == (*it).second.vars.size()); // this should always be true
|
||||
size_t count = sb->Variables.size();
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
if (! ( *sb->Variables[i] == *(*it).second.vars[i] ) )
|
||||
|
@ -18,12 +18,12 @@ namespace JSI_LookedupWord {
|
||||
static JSBool GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
CLocale::LookupType* lookedup = (CLocale::LookupType*)JS_GetPrivate(cx, obj);
|
||||
assert(lookedup);
|
||||
debug_assert(lookedup);
|
||||
|
||||
JSObject* parent = JS_GetParent(cx, obj);
|
||||
assert(parent);
|
||||
debug_assert(parent);
|
||||
CLocale* locale = (CLocale*)JS_GetPrivate(cx, parent);
|
||||
assert(locale);
|
||||
debug_assert(locale);
|
||||
|
||||
JSString* prop = JS_ValueToString(cx, id);
|
||||
JS_ASSERT(prop, "lookup() property failed to convert to string");
|
||||
@ -50,7 +50,7 @@ namespace JSI_LookedupWord {
|
||||
// Free the LookupType that was allocated when building this object
|
||||
|
||||
CLocale::LookupType* lookedup = (CLocale::LookupType*)JS_GetPrivate(cx, obj);
|
||||
assert(lookedup);
|
||||
debug_assert(lookedup);
|
||||
delete lookedup;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
// Vaguely useful utility function for deleting stuff
|
||||
template<typename T> void delete_fn(T* v) { delete v; }
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ps/CLogger.h"
|
||||
|
@ -208,7 +208,7 @@ public:
|
||||
l->refs++;
|
||||
else
|
||||
{
|
||||
assert(l->refs > 0);
|
||||
debug_assert(l->refs > 0);
|
||||
l->refs--;
|
||||
}
|
||||
return 0;
|
||||
|
@ -153,7 +153,7 @@ void get_snd_info()
|
||||
#else
|
||||
// At least reset the values for unhandled platforms. Should perhaps do
|
||||
// something like storing the OpenAL version or similar.
|
||||
assert(SND_CARD_LEN >= 8 && SND_DRV_VER_LEN >= 8); // protect strcpy
|
||||
debug_assert(SND_CARD_LEN >= 8 && SND_DRV_VER_LEN >= 8); // protect strcpy
|
||||
strcpy(snd_card, "Unknown"); // safe
|
||||
strcpy(snd_drv_ver, "Unknown"); // safe
|
||||
#endif
|
||||
|
@ -91,7 +91,7 @@ struct Active
|
||||
Active& operator=(Descriptor* desc)
|
||||
{
|
||||
*(Descriptor**)this = desc;
|
||||
assert(credits == 0); // make sure ptr is aligned
|
||||
debug_assert(credits == 0); // make sure ptr is aligned
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -502,7 +502,7 @@ return pool;
|
||||
|
||||
// need to set up a new pool
|
||||
// .. but there are too many
|
||||
assert2(0 <= num_pools && num_pools <= MAX_POOLS);
|
||||
debug_assert(0 <= num_pools && num_pools <= MAX_POOLS);
|
||||
if(num_pools >= MAX_POOLS)
|
||||
{
|
||||
debug_warn("increase MAX_POOLS");
|
||||
|
@ -141,7 +141,7 @@ static void tls_retire(void* tls_)
|
||||
if(CAS(&tls->active, 1, 0))
|
||||
{
|
||||
atomic_add(&active_threads, -1);
|
||||
assert2(active_threads >= 0);
|
||||
debug_assert(active_threads >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ static void tls_retire(void* tls_)
|
||||
static void tls_init()
|
||||
{
|
||||
int ret = pthread_key_create(&tls_key, tls_retire);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +158,7 @@ static void tls_init()
|
||||
static void tls_shutdown()
|
||||
{
|
||||
int ret = pthread_key_delete(tls_key);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
tls_key = 0;
|
||||
|
||||
while(tls_list)
|
||||
@ -178,7 +178,7 @@ static TLS* tls_alloc()
|
||||
{
|
||||
// make sure we weren't shut down in the meantime - re-init isn't
|
||||
// possible since pthread_once (which can't be reset) calls tls_init.
|
||||
assert2(tls_key != 0);
|
||||
debug_assert(tls_key != 0);
|
||||
|
||||
TLS* tls;
|
||||
|
||||
@ -198,7 +198,7 @@ static TLS* tls_alloc()
|
||||
{
|
||||
tls = (TLS*)-1;
|
||||
int ret = pthread_setspecific(tls_key, tls);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
return tls;
|
||||
}
|
||||
tls->active = 1;
|
||||
@ -217,7 +217,7 @@ have_tls:
|
||||
atomic_add(&active_threads, 1);
|
||||
|
||||
int ret = pthread_setspecific(tls_key, tls);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
return tls;
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ have_tls:
|
||||
static TLS* tls_get()
|
||||
{
|
||||
int ret = pthread_once(&tls_once, tls_init);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
|
||||
// already allocated or tls_alloc failed.
|
||||
TLS* tls = (TLS*)pthread_getspecific(tls_key);
|
||||
@ -267,7 +267,7 @@ static void smr_release_unreferenced_nodes(TLS* tls)
|
||||
return;
|
||||
|
||||
// required for head/tail below; guaranteed by callers.
|
||||
assert2(tls->num_retired_nodes != 0);
|
||||
debug_assert(tls->num_retired_nodes != 0);
|
||||
|
||||
//
|
||||
// build array of all active (non-NULL) hazard pointers (more efficient
|
||||
@ -331,7 +331,7 @@ retry:
|
||||
static void smr_retire_node(Node* node)
|
||||
{
|
||||
TLS* tls = tls_get();
|
||||
assert2(tls != (void*)-1);
|
||||
debug_assert(tls != (void*)-1);
|
||||
// if this triggers, tls_alloc called from lfl_init failed due to
|
||||
// lack of memory and the caller didn't check its return value.
|
||||
|
||||
@ -422,13 +422,13 @@ static inline bool is_marked_as_deleted(Node* p)
|
||||
|
||||
static inline Node* with_mark(Node* p)
|
||||
{
|
||||
assert2(!is_marked_as_deleted(p)); // paranoia
|
||||
debug_assert(!is_marked_as_deleted(p)); // paranoia
|
||||
return p+1;
|
||||
}
|
||||
|
||||
static inline Node* without_mark(Node* p)
|
||||
{
|
||||
assert2(is_marked_as_deleted(p)); // paranoia
|
||||
debug_assert(is_marked_as_deleted(p)); // paranoia
|
||||
return p-1;
|
||||
}
|
||||
|
||||
@ -472,7 +472,7 @@ void lfl_free(LFList* list)
|
||||
}
|
||||
|
||||
atomic_add(&active_data_structures, -1);
|
||||
assert2(active_data_structures >= 0);
|
||||
debug_assert(active_data_structures >= 0);
|
||||
smr_try_shutdown();
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ void lfl_free(LFList* list)
|
||||
static bool list_lookup(LFList* list, uintptr_t key, ListPos* pos)
|
||||
{
|
||||
TLS* tls = tls_get();
|
||||
assert2(tls != (void*)-1);
|
||||
debug_assert(tls != (void*)-1);
|
||||
// if this triggers, tls_alloc called from lfl_init failed due to
|
||||
// lack of memory and the caller didn't check its return value.
|
||||
|
||||
@ -567,7 +567,7 @@ void* lfl_find(LFList* list, uintptr_t key)
|
||||
void* lfl_insert(LFList* list, uintptr_t key, size_t additional_bytes, int* was_inserted)
|
||||
{
|
||||
TLS* tls = tls_get();
|
||||
assert2(tls != (void*)-1);
|
||||
debug_assert(tls != (void*)-1);
|
||||
// if this triggers, tls_alloc called from lfl_init failed due to
|
||||
// lack of memory and the caller didn't check its return value.
|
||||
|
||||
@ -620,7 +620,7 @@ have_node:
|
||||
int lfl_erase(LFList* list, uintptr_t key)
|
||||
{
|
||||
TLS* tls = tls_get();
|
||||
assert2(tls != (void*)-1);
|
||||
debug_assert(tls != (void*)-1);
|
||||
// if this triggers, tls_alloc called from lfl_init failed due to
|
||||
// lack of memory and the caller didn't check its return value.
|
||||
|
||||
@ -660,8 +660,8 @@ retry:
|
||||
|
||||
static void validate(LFHash* hash)
|
||||
{
|
||||
assert2(hash->tbl);
|
||||
assert2(is_pow2(hash->mask+1));
|
||||
debug_assert(hash->tbl);
|
||||
debug_assert(is_pow2(hash->mask+1));
|
||||
}
|
||||
|
||||
// return hash "chain" (i.e. linked list) that is assigned to <key>.
|
||||
@ -769,11 +769,11 @@ static void basic_single_threaded_test()
|
||||
|
||||
LFList list;
|
||||
err = lfl_init(&list);
|
||||
assert2(err == 0);
|
||||
debug_assert(err == 0);
|
||||
|
||||
LFHash hash;
|
||||
err = lfh_init(&hash, 8);
|
||||
assert2(err == 0);
|
||||
debug_assert(err == 0);
|
||||
|
||||
// add some entries; store "signatures" (ascending int values)
|
||||
for(uint i = 0; i < ENTRIES; i++)
|
||||
@ -781,11 +781,11 @@ static void basic_single_threaded_test()
|
||||
int was_inserted;
|
||||
|
||||
user_data = lfl_insert(&list, key+i, sizeof(int), &was_inserted);
|
||||
assert2(user_data != 0 && was_inserted);
|
||||
debug_assert(user_data != 0 && was_inserted);
|
||||
*(int*)user_data = sig+i;
|
||||
|
||||
user_data = lfh_insert(&hash, key+i, sizeof(int), &was_inserted);
|
||||
assert2(user_data != 0 && was_inserted);
|
||||
debug_assert(user_data != 0 && was_inserted);
|
||||
*(int*)user_data = sig+i;
|
||||
}
|
||||
|
||||
@ -793,12 +793,12 @@ static void basic_single_threaded_test()
|
||||
for(uint i = 0; i < ENTRIES; i++)
|
||||
{
|
||||
user_data = lfl_find(&list, key+i);
|
||||
assert2(user_data != 0);
|
||||
assert2(*(int*)user_data == sig+i);
|
||||
debug_assert(user_data != 0);
|
||||
debug_assert(*(int*)user_data == sig+i);
|
||||
|
||||
user_data = lfh_find(&hash, key+i);
|
||||
assert2(user_data != 0);
|
||||
assert2(*(int*)user_data == sig+i);
|
||||
debug_assert(user_data != 0);
|
||||
debug_assert(*(int*)user_data == sig+i);
|
||||
|
||||
}
|
||||
|
||||
@ -866,15 +866,15 @@ static void* thread_func(void* arg)
|
||||
case TA_FIND:
|
||||
{
|
||||
user_data = lfl_find(&list, key);
|
||||
assert2(was_in_set == (user_data != 0));
|
||||
debug_assert(was_in_set == (user_data != 0));
|
||||
if(user_data)
|
||||
assert2(*(uintptr_t*)user_data == ~key);
|
||||
debug_assert(*(uintptr_t*)user_data == ~key);
|
||||
|
||||
user_data = lfh_find(&hash, key);
|
||||
// typical failure site if lockfree data structure has bugs.
|
||||
assert2(was_in_set == (user_data != 0));
|
||||
debug_assert(was_in_set == (user_data != 0));
|
||||
if(user_data)
|
||||
assert2(*(uintptr_t*)user_data == ~key);
|
||||
debug_assert(*(uintptr_t*)user_data == ~key);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -883,14 +883,14 @@ static void* thread_func(void* arg)
|
||||
int was_inserted;
|
||||
|
||||
user_data = lfl_insert(&list, key, sizeof(uintptr_t), &was_inserted);
|
||||
assert2(user_data != 0); // only triggers if out of memory
|
||||
debug_assert(user_data != 0); // only triggers if out of memory
|
||||
*(uintptr_t*)user_data = ~key; // checked above
|
||||
assert2(was_in_set == !was_inserted);
|
||||
debug_assert(was_in_set == !was_inserted);
|
||||
|
||||
user_data = lfh_insert(&hash, key, sizeof(uintptr_t), &was_inserted);
|
||||
assert2(user_data != 0); // only triggers if out of memory
|
||||
debug_assert(user_data != 0); // only triggers if out of memory
|
||||
*(uintptr_t*)user_data = ~key; // checked above
|
||||
assert2(was_in_set == !was_inserted);
|
||||
debug_assert(was_in_set == !was_inserted);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -899,10 +899,10 @@ static void* thread_func(void* arg)
|
||||
int err;
|
||||
|
||||
err = lfl_erase(&list, key);
|
||||
assert2(was_in_set == (err == 0));
|
||||
debug_assert(was_in_set == (err == 0));
|
||||
|
||||
err = lfh_erase(&hash, key);
|
||||
assert2(was_in_set == (err == 0));
|
||||
debug_assert(was_in_set == (err == 0));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -917,7 +917,7 @@ static void* thread_func(void* arg)
|
||||
} // while !is_complete
|
||||
|
||||
atomic_add(&num_active_threads, -1);
|
||||
assert2(num_active_threads >= 0);
|
||||
debug_assert(num_active_threads >= 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -935,11 +935,11 @@ static void multithreaded_torture_test()
|
||||
is_complete = false;
|
||||
|
||||
err = lfl_init(&list);
|
||||
assert2(err == 0);
|
||||
debug_assert(err == 0);
|
||||
err = lfh_init(&hash, 128);
|
||||
assert2(err == 0);
|
||||
debug_assert(err == 0);
|
||||
err = pthread_mutex_init(&mutex, 0);
|
||||
assert2(err == 0);
|
||||
debug_assert(err == 0);
|
||||
|
||||
// spin off test threads (many, to force preemption)
|
||||
const uint NUM_THREADS = 16;
|
||||
@ -959,7 +959,7 @@ static void multithreaded_torture_test()
|
||||
lfl_free(&list);
|
||||
lfh_free(&hash);
|
||||
err = pthread_mutex_destroy(&mutex);
|
||||
assert2(err == 0);
|
||||
debug_assert(err == 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
@ -60,7 +60,7 @@ static void lock_init() throw()
|
||||
static void lock_shutdown() throw()
|
||||
{
|
||||
int ret = pthread_mutex_destroy(&mutex);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
lock_initialized = false;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ static void lock() throw()
|
||||
if(lock_initialized)
|
||||
{
|
||||
int ret = pthread_mutex_lock(&mutex);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ static void unlock() throw()
|
||||
if(lock_initialized)
|
||||
{
|
||||
int ret = pthread_mutex_unlock(&mutex);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ uint mmgr_set_options(uint new_options)
|
||||
|
||||
if(new_options != MMGR_QUERY)
|
||||
{
|
||||
assert2(!(new_options & ~MMGR_ALL) && "unrecognized options set");
|
||||
debug_assert(!(new_options & ~MMGR_ALL) && "unrecognized options set");
|
||||
options = new_options;
|
||||
}
|
||||
uint ret = options;
|
||||
@ -139,7 +139,7 @@ static const char* insert_commas(char* out, size_t value)
|
||||
char num[NUM_SIZE];
|
||||
sprintf(num, "%u", value);
|
||||
const size_t num_len = strlen(num);
|
||||
assert2(num_len != 0); // messes up #comma calc below
|
||||
debug_assert(num_len != 0); // messes up #comma calc below
|
||||
|
||||
const size_t out_len = num_len + (num_len-1)/3;
|
||||
char* pos = out+out_len;
|
||||
@ -247,7 +247,7 @@ static Alloc* alloc_new()
|
||||
freelist = (Alloc*)calloc(256, sizeof(Alloc));
|
||||
if(!freelist)
|
||||
{
|
||||
assert2(0 && "mmgr: failed to allocate freelist (out of memory)");
|
||||
debug_assert(0 && "mmgr: failed to allocate freelist (out of memory)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ static Alloc* alloc_new()
|
||||
|
||||
const size_t bytes = (num_reservoirs + 1) * sizeof(Alloc*);
|
||||
Alloc* *temp = (Alloc* *) realloc(reservoirs, bytes);
|
||||
assert2(temp);
|
||||
debug_assert(temp);
|
||||
if(temp)
|
||||
{
|
||||
reservoirs = temp;
|
||||
@ -347,7 +347,7 @@ static void allocs_add(Alloc* a)
|
||||
static Alloc* allocs_find(const void* user_p)
|
||||
{
|
||||
if(!user_p)
|
||||
assert2(user_p);
|
||||
debug_assert(user_p);
|
||||
|
||||
Alloc* a = hash_chain(user_p);
|
||||
while(a)
|
||||
@ -605,7 +605,7 @@ static void log_init()
|
||||
log_fp = fopen(log_filename, "w");
|
||||
if(!log_fp)
|
||||
{
|
||||
assert2(0 && "log file open failed");
|
||||
debug_assert(0 && "log file open failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -702,7 +702,7 @@ void mmgr_write_report(void)
|
||||
FILE* f = fopen("mem_report.txt", "w");
|
||||
if(!f)
|
||||
{
|
||||
assert2(0 && "open of memory report file failed");
|
||||
debug_assert(0 && "open of memory report file failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -769,7 +769,7 @@ void mmgr_write_leak_report(void)
|
||||
FILE* f = fopen("mem_leaks.txt", "w");
|
||||
if(!f)
|
||||
{
|
||||
assert2(0 && "open of memory leak report file failed");
|
||||
debug_assert(0 && "open of memory leak report file failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -827,7 +827,7 @@ static bool alloc_is_valid(const Alloc* a)
|
||||
|
||||
// this allocation has been over/underrun, i.e. modified outside the
|
||||
// allocation's memory range.
|
||||
assert2(0 && "Memory over/underrun detected by mmgr");
|
||||
debug_assert(0 && "Memory over/underrun detected by mmgr");
|
||||
log("[!] Memory over/underrun:\n");
|
||||
log_this_alloc(a);
|
||||
return false;
|
||||
@ -861,13 +861,13 @@ static bool validate_all()
|
||||
// enable MMGR_VALIDATE_ALL, trigger this condition again,
|
||||
// and check the log for the last successful operation. the problem
|
||||
// will have occurred between then and now.
|
||||
assert2(0);
|
||||
debug_assert(0);
|
||||
log("[!] Memory tracking hash table corrupt!\n");
|
||||
}
|
||||
|
||||
if(params.num_invalid)
|
||||
{
|
||||
assert2(0);
|
||||
debug_assert(0);
|
||||
log("[!] %d allocations are corrupt\n", params.num_invalid);
|
||||
}
|
||||
|
||||
@ -951,13 +951,13 @@ void mmgr_break_on_realloc(const void* p)
|
||||
Alloc* a = allocs_find(p);
|
||||
if(!a)
|
||||
{
|
||||
assert2(0 && "setting realloc breakpoint on invalid pointer");
|
||||
debug_assert(0 && "setting realloc breakpoint on invalid pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
// setting realloc breakpoint on an allocation that
|
||||
// doesn't support realloc.
|
||||
assert2(a->type == AT_MALLOC || a->type == AT_CALLOC ||
|
||||
debug_assert(a->type == AT_MALLOC || a->type == AT_CALLOC ||
|
||||
a->type == AT_REALLOC);
|
||||
|
||||
a->break_on_realloc = true;
|
||||
@ -973,7 +973,7 @@ void mmgr_break_on_free(const void* p)
|
||||
Alloc* a = allocs_find(p);
|
||||
if(!a)
|
||||
{
|
||||
assert2(0 && "setting free breakpoint on invalid pointer");
|
||||
debug_assert(0 && "setting free breakpoint on invalid pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1003,11 +1003,11 @@ void* alloc_dbg(size_t user_size, AllocType type, const char* file, int line, co
|
||||
log("[+] %05d %8s of size 0x%08X(%08d) by %s\n", cur_alloc_count, types[type], user_size, user_size, caller_string);
|
||||
|
||||
// caller's source file didn't include "mmgr.h"
|
||||
assert2(type != AT_UNKNOWN);
|
||||
debug_assert(type != AT_UNKNOWN);
|
||||
|
||||
// you requested a breakpoint on this allocation number
|
||||
++cur_alloc_count;
|
||||
assert2(cur_alloc_count != break_on_count);
|
||||
debug_assert(cur_alloc_count != break_on_count);
|
||||
|
||||
// simulate random failures
|
||||
#ifdef RANDOM_FAILURE
|
||||
@ -1026,7 +1026,7 @@ void* alloc_dbg(size_t user_size, AllocType type, const char* file, int line, co
|
||||
void* p = malloc(size);
|
||||
if(!p)
|
||||
{
|
||||
assert2(0);
|
||||
debug_assert(0);
|
||||
log("[!] Allocation failed (out of memory)\n");
|
||||
goto fail;
|
||||
}
|
||||
@ -1094,16 +1094,16 @@ void free_dbg(const void* user_p, AllocType type, const char* file, int line, co
|
||||
if(!a)
|
||||
{
|
||||
// you tried to free a pointer mmgr didn't allocate
|
||||
assert2(0 && "mmgr tried to free a pointer mmgr didn't allocate");
|
||||
debug_assert(0 && "mmgr tried to free a pointer mmgr didn't allocate");
|
||||
log("[!] mmgr_free: not allocated by this memory manager\n");
|
||||
goto fail;
|
||||
}
|
||||
// .. overrun? (note: alloc_is_valid already asserts if invalid)
|
||||
alloc_is_valid(a);
|
||||
// .. the owner wasn't compiled with mmgr.h
|
||||
assert2(type != AT_UNKNOWN);
|
||||
debug_assert(type != AT_UNKNOWN);
|
||||
// .. allocator / deallocator type mismatch
|
||||
assert2(
|
||||
debug_assert(
|
||||
(type == AT_DELETE && a->type == AT_NEW ) ||
|
||||
(type == AT_DELETE_ARRAY && a->type == AT_NEW_ARRAY) ||
|
||||
(type == AT_FREE && a->type == AT_MALLOC ) ||
|
||||
@ -1111,7 +1111,7 @@ void free_dbg(const void* user_p, AllocType type, const char* file, int line, co
|
||||
(type == AT_FREE && a->type == AT_REALLOC )
|
||||
);
|
||||
// .. you requested a breakpoint when freeing this allocation
|
||||
assert2(!a->break_on_free);
|
||||
debug_assert(!a->break_on_free);
|
||||
|
||||
|
||||
// "poison" the allocation's memory, to catch use-after-free bugs.
|
||||
@ -1157,7 +1157,7 @@ void* realloc_dbg(const void* user_p, size_t user_size, AllocType type, const ch
|
||||
void* ret = 0;
|
||||
uint old_size = 0;
|
||||
|
||||
assert2(type == AT_REALLOC);
|
||||
debug_assert(type == AT_REALLOC);
|
||||
|
||||
lock();
|
||||
|
||||
@ -1175,18 +1175,18 @@ void* realloc_dbg(const void* user_p, size_t user_size, AllocType type, const ch
|
||||
if(!a)
|
||||
{
|
||||
// you called realloc for a pointer mmgr didn't allocate
|
||||
assert2(0 && "realloc was called for a pointer mmgr didn't allocate");
|
||||
debug_assert(0 && "realloc was called for a pointer mmgr didn't allocate");
|
||||
log("[!] realloc: wasn't previously allocated\n");
|
||||
goto fail;
|
||||
}
|
||||
// .. the owner wasn't compiled with mmgr.h
|
||||
assert2(a->type != AT_UNKNOWN);
|
||||
debug_assert(a->type != AT_UNKNOWN);
|
||||
// .. realloc for an allocation type that doesn't support it.
|
||||
assert2(a->type == AT_MALLOC || a->type == AT_CALLOC ||
|
||||
debug_assert(a->type == AT_MALLOC || a->type == AT_CALLOC ||
|
||||
a->type == AT_REALLOC);
|
||||
// .. you requested a breakpoint when reallocating this allocation
|
||||
// (it will continue to be triggered unless you clear a->break_on_realloc)
|
||||
assert2(!a->break_on_realloc);
|
||||
debug_assert(!a->break_on_realloc);
|
||||
|
||||
old_size = a->size;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ extern void operator delete[](void* p, const char* file, int line, const char* f
|
||||
// fixing your bugs
|
||||
// ----------------
|
||||
//
|
||||
// if this code crashes or fails an assert, it is most likely due to a bug
|
||||
// if this code crashes or fails an debug_assert, it is most likely due to a bug
|
||||
// in your application. consult the current Alloc for information;
|
||||
// search the log for its address to determine what operation failed,
|
||||
// and what piece of code owns the allocation.
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
@ -61,7 +61,7 @@ static bool have_14, have_13, have_12;
|
||||
// (useful for crash logs).
|
||||
const char* oglExtList()
|
||||
{
|
||||
assert(exts && "call oglInit before using this function");
|
||||
debug_assert(exts && "call oglInit before using this function");
|
||||
return exts;
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ static bool isImplementedInCore(const char* ext)
|
||||
// takes subsequently added core support for some extensions into account.
|
||||
bool oglHaveExtension(const char* ext)
|
||||
{
|
||||
assert(exts && "call oglInit before using this function");
|
||||
debug_assert(exts && "call oglInit before using this function");
|
||||
|
||||
if(isImplementedInCore(ext))
|
||||
return true;
|
||||
@ -388,9 +388,9 @@ static void CALL_CONV emulate_glCompressedTexImage2D(
|
||||
bool dxt1 = (internalformat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || internalformat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
|
||||
bool dxt3 = (internalformat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
|
||||
bool dxt5 = (internalformat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
|
||||
assert(dxt1 || dxt3 || dxt5);
|
||||
debug_assert(dxt1 || dxt3 || dxt5);
|
||||
|
||||
assert(imageSize == blocks * (dxt1? 8 : 16));
|
||||
debug_assert(imageSize == blocks * (dxt1? 8 : 16));
|
||||
|
||||
// This code is inefficient, but I don't care:
|
||||
|
||||
|
@ -150,7 +150,7 @@ static int Cursor_reload(Cursor* c, const char* name, Handle)
|
||||
else
|
||||
{
|
||||
// TODO: Handle errors
|
||||
assert(! "Cursor texture not 32-bit RGBA/BGRA");
|
||||
debug_assert(! "Cursor texture not 32-bit RGBA/BGRA");
|
||||
|
||||
tex_free(tex);
|
||||
|
||||
@ -180,7 +180,7 @@ static int Cursor_reload(Cursor* c, const char* name, Handle)
|
||||
if (! iconbitmap)
|
||||
{
|
||||
// TODO: Handle errors
|
||||
assert(! "Error creating icon DIB");
|
||||
debug_assert(! "Error creating icon DIB");
|
||||
|
||||
if (imgdata_bgra != imgdata) delete[] imgdata_bgra;
|
||||
tex_free(tex);
|
||||
@ -195,7 +195,7 @@ static int Cursor_reload(Cursor* c, const char* name, Handle)
|
||||
if (! cursor)
|
||||
{
|
||||
// TODO: Handle errors
|
||||
assert(! "Error creating cursor");
|
||||
debug_assert(! "Error creating cursor");
|
||||
|
||||
if (imgdata_bgra != imgdata) delete[] imgdata_bgra;
|
||||
tex_free(tex);
|
||||
|
@ -835,7 +835,7 @@ static u64 block_make_id(const u32 fn_hash, const off_t ofs)
|
||||
|
||||
// make sure block_num fits in 32 bits
|
||||
const size_t block_num = ofs / BLOCK_SIZE;
|
||||
assert(block_num <= 0xffffffff);
|
||||
debug_assert(block_num <= 0xffffffff);
|
||||
|
||||
u64 id = fn_hash; // careful, don't shift a u32 32 bits left
|
||||
id <<= 32;
|
||||
@ -1184,7 +1184,7 @@ if(from_cache && !temp)
|
||||
if(err < 0)
|
||||
return err;
|
||||
|
||||
assert(issue_cnt >= raw_transferred_cnt && raw_transferred_cnt >= data_size);
|
||||
debug_assert(issue_cnt >= raw_transferred_cnt && raw_transferred_cnt >= data_size);
|
||||
|
||||
return (ssize_t)actual_transferred_cnt;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "lib.h"
|
||||
#include "res.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <limits.h> // CHAR_BIT
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -91,13 +91,13 @@ static inline u32 h_tag(const Handle h)
|
||||
static inline Handle handle(const u32 _idx, const u32 tag)
|
||||
{
|
||||
const u32 idx = _idx+1;
|
||||
assert(idx <= IDX_MASK && tag <= TAG_MASK && "handle: idx or tag too big");
|
||||
debug_assert(idx <= IDX_MASK && tag <= TAG_MASK && "handle: idx or tag too big");
|
||||
// somewhat clunky, but be careful with the shift:
|
||||
// *_SHIFT may be larger than its field's type.
|
||||
Handle h_idx = idx & IDX_MASK; h_idx <<= IDX_SHIFT;
|
||||
Handle h_tag = tag & TAG_MASK; h_tag <<= TAG_SHIFT;
|
||||
Handle h = h_idx | h_tag;
|
||||
assert(h > 0);
|
||||
debug_assert(h > 0);
|
||||
return h;
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ static int alloc_idx(i32& idx, HDATA*& hd)
|
||||
for(idx = 0; idx <= last_in_use; idx++)
|
||||
{
|
||||
hd = h_data_from_idx(idx);
|
||||
assert(hd); // can't fail - idx is valid
|
||||
debug_assert(hd); // can't fail - idx is valid
|
||||
|
||||
// found one - done
|
||||
if(!hd->tag)
|
||||
@ -283,7 +283,7 @@ static int alloc_idx(i32& idx, HDATA*& hd)
|
||||
// add another
|
||||
if(last_in_use >= hdata_cap)
|
||||
{
|
||||
assert(!"alloc_idx: too many open handles (increase IDX_BITS)");
|
||||
debug_assert(!"alloc_idx: too many open handles (increase IDX_BITS)");
|
||||
return ERR_LIMIT;
|
||||
}
|
||||
idx = last_in_use+1; // just incrementing idx would start it at 1
|
||||
@ -293,7 +293,7 @@ static int alloc_idx(i32& idx, HDATA*& hd)
|
||||
// can't fail for any other reason - idx is checked above.
|
||||
{ // VC6 goto fix
|
||||
bool is_unused = !hd->tag;
|
||||
assert(is_unused && "alloc_idx: invalid last_in_use");
|
||||
debug_assert(is_unused && "alloc_idx: invalid last_in_use");
|
||||
}
|
||||
|
||||
have_idx:;
|
||||
@ -373,7 +373,7 @@ static void add_key(uintptr_t key, Handle h)
|
||||
static void remove_key(uintptr_t key, H_Type type)
|
||||
{
|
||||
Handle ret = find_key(key, type, true);
|
||||
assert(ret > 0);
|
||||
debug_assert(ret > 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -359,7 +359,7 @@ guide to defining and using resources
|
||||
}
|
||||
|
||||
again no provision for reporting errors - there's no one to act on it
|
||||
if called at exit. you can assert or log the error, though.
|
||||
if called at exit. you can debug_assert or log the error, though.
|
||||
|
||||
5) provide your layer on top of the handle manager:
|
||||
Handle res1_load(const char* filename, int my_flags)
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "res.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -105,7 +105,7 @@ static void remove_alloc(void* raw_p)
|
||||
{
|
||||
size_t num_removed = ptr_to_h.erase(raw_p);
|
||||
if(num_removed != 1)
|
||||
assert(num_removed == 1 && "remove_alloc: not in map");
|
||||
debug_assert(num_removed == 1 && "remove_alloc: not in map");
|
||||
}
|
||||
|
||||
|
||||
@ -388,7 +388,7 @@ void* mem_get_ptr(Handle hm, size_t* user_size /* = 0 */)
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert((!m->p || m->size) && "mem_get_ptr: mem corrupted (p valid =/=> size > 0)");
|
||||
debug_assert((!m->p || m->size) && "mem_get_ptr: mem corrupted (p valid =/=> size > 0)");
|
||||
|
||||
if(user_size)
|
||||
*user_size = m->size;
|
||||
|
@ -128,7 +128,7 @@ void ogg_open(void* _o, ALenum& fmt, ALsizei& freq)
|
||||
void* datasource = &o->incoming_bufs;
|
||||
if(ov_open_callbacks(datasource, &o->oggStream, NULL, 0, cbs) < 0)
|
||||
{
|
||||
assert(!"ov_open failed");
|
||||
debug_assert(!"ov_open failed");
|
||||
}
|
||||
|
||||
o->vorbisInfo = ov_info(&o->oggStream, -1);
|
||||
@ -166,7 +166,7 @@ size_t ogg_read(void* _o, void* buf, size_t max_size)
|
||||
if(result > 0)
|
||||
bytes_written += result;
|
||||
else if(result < 0)
|
||||
assert(!"ogg read error");
|
||||
debug_assert(!"ogg read error");
|
||||
// clean break - end of data
|
||||
else
|
||||
break;
|
||||
|
@ -109,13 +109,13 @@ static int get_gl_fmt(int bpp, int flags, GLenum* fmt, GLenum* int_fmt)
|
||||
*int_fmt = high_quality? GL_LUMINANCE8_ALPHA8 : GL_LUMINANCE4_ALPHA4;
|
||||
return 0;
|
||||
case 24:
|
||||
assert(!alpha);
|
||||
debug_assert(!alpha);
|
||||
*fmt = bgr? GL_BGR : GL_RGB;
|
||||
*int_fmt = high_quality? GL_RGB8 : GL_RGB4;
|
||||
// note: BGR can't be used as internal format
|
||||
return 0;
|
||||
case 32:
|
||||
assert(alpha);
|
||||
debug_assert(alpha);
|
||||
*fmt = bgr? GL_BGRA : GL_RGBA;
|
||||
*int_fmt = high_quality? GL_RGBA8 : GL_RGBA4;
|
||||
// note: BGR can't be used as internal format
|
||||
@ -126,7 +126,7 @@ static int get_gl_fmt(int bpp, int flags, GLenum* fmt, GLenum* int_fmt)
|
||||
}
|
||||
|
||||
// unreachable
|
||||
assert(0);
|
||||
debug_assert(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
# include "sysdep/win/win_internal.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define OGG_HACK
|
||||
#include "ogghack.h"
|
||||
|
||||
@ -104,7 +105,7 @@ static void hsd_list_free_all();
|
||||
// 1 error at a time, so this is called after every OpenAL request.
|
||||
static void al_check(const char* caller = "(unknown)")
|
||||
{
|
||||
assert(al_initialized);
|
||||
debug_assert(al_initialized);
|
||||
|
||||
ALenum err = alGetError();
|
||||
if(err == AL_NO_ERROR)
|
||||
@ -206,6 +207,21 @@ static int alc_init()
|
||||
dlls[2] = LoadLibrary("wdmaud.drv");
|
||||
#endif
|
||||
|
||||
// for reasons unknown, the NV native OpenAL implementation
|
||||
// causes an invalid exception internally when loaded (it's not
|
||||
// caused by the DLL load hack above). we need to catch it to
|
||||
// prevent the unhandled exception filter from reporting it.
|
||||
#ifdef _WIN32
|
||||
__try
|
||||
{
|
||||
alc_dev = alcOpenDevice((ALubyte*)alc_dev_name);
|
||||
}
|
||||
__except(1) // EXCEPTION_E XECUTE_HANDLER
|
||||
{
|
||||
debug_assert(!"hit me");
|
||||
}
|
||||
#endif
|
||||
|
||||
alc_dev = alcOpenDevice((ALubyte*)alc_dev_name);
|
||||
if(alc_dev)
|
||||
{
|
||||
@ -337,7 +353,7 @@ static void al_buf_free(ALuint al_buf)
|
||||
if(!al_buf)
|
||||
return;
|
||||
|
||||
assert(alIsBuffer(al_buf));
|
||||
debug_assert(alIsBuffer(al_buf));
|
||||
alDeleteBuffers(1, &al_buf);
|
||||
al_check("al_buf_free");
|
||||
|
||||
@ -386,7 +402,7 @@ static void al_src_init()
|
||||
// we've reached the limit, no more are available.
|
||||
if(alGetError() != AL_NO_ERROR)
|
||||
break;
|
||||
assert(alIsSource(al_srcs[i]));
|
||||
debug_assert(alIsSource(al_srcs[i]));
|
||||
al_src_allocated++;
|
||||
}
|
||||
|
||||
@ -396,7 +412,7 @@ static void al_src_init()
|
||||
al_src_cap = al_src_allocated;
|
||||
|
||||
// make sure we got the minimum guaranteed by OpenAL.
|
||||
assert(al_src_allocated >= 16);
|
||||
debug_assert(al_src_allocated >= 16);
|
||||
}
|
||||
|
||||
|
||||
@ -405,7 +421,7 @@ static void al_src_init()
|
||||
// called from al_shutdown.
|
||||
static void al_src_shutdown()
|
||||
{
|
||||
assert(al_src_used == 0);
|
||||
debug_assert(al_src_used == 0);
|
||||
alDeleteSources(al_src_allocated, al_srcs);
|
||||
al_src_allocated = 0;
|
||||
al_check("al_src_shutdown");
|
||||
@ -424,9 +440,9 @@ static ALuint al_src_alloc()
|
||||
|
||||
static void al_src_free(ALuint al_src)
|
||||
{
|
||||
assert(alIsSource(al_src));
|
||||
debug_assert(alIsSource(al_src));
|
||||
al_srcs[--al_src_used] = al_src;
|
||||
assert(al_src_used < al_src_allocated);
|
||||
debug_assert(al_src_used < al_src_allocated);
|
||||
// don't compare against cap - it might have been
|
||||
// decreased to less than were in use.
|
||||
}
|
||||
@ -598,7 +614,7 @@ static void* io_buf_freelist;
|
||||
|
||||
static void io_buf_free(void* p)
|
||||
{
|
||||
assert(io_bufs <= p && p <= (char*)io_bufs+TOTAL_BUF_SIZE);
|
||||
debug_assert(io_bufs <= p && p <= (char*)io_bufs+TOTAL_BUF_SIZE);
|
||||
*(void**)p = io_buf_freelist;
|
||||
io_buf_freelist = p;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -1025,7 +1025,7 @@ fail:
|
||||
png_read_image(png_ptr, (png_bytepp)rows);
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
|
||||
assert(f.p == file && f.size == file_size && f.pos == f.size);
|
||||
debug_assert(f.p == file && f.size == file_size && f.pos == f.size);
|
||||
|
||||
// store image info
|
||||
mem_free_h(t->hm);
|
||||
|
@ -19,7 +19,7 @@ Unicode OpenGL texture font
|
||||
#include <map>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/*/*#include <ps/CLogger.h>
|
||||
#define LOG_CATEGORY "graphics"*/
|
||||
@ -154,7 +154,7 @@ static int UniFont_reload(UniFont* f, const char* fn, Handle UNUSEDPARAM(h))
|
||||
(*f->glyphs_size)[(wchar_t)Codepoint] = Advance;
|
||||
}
|
||||
|
||||
assert(f->Height); // Ensure the height has been found (which should always happen if the font includes an 'I')
|
||||
debug_assert(f->Height); // Ensure the height has been found (which should always happen if the font includes an 'I')
|
||||
|
||||
// Load glyph texture
|
||||
std::string FilenameTex = FilenameBase+".tga";
|
||||
@ -232,7 +232,7 @@ void glvwprintf(const wchar_t* fmt, va_list args)
|
||||
// Make sure there's always null termination
|
||||
buf[buf_size-1] = 0;
|
||||
|
||||
assert(BoundGlyphs != NULL); // You always need to bind something first
|
||||
debug_assert(BoundGlyphs != NULL); // You always need to bind something first
|
||||
|
||||
// Count the number of characters
|
||||
size_t len = wcslen(buf);
|
||||
|
@ -647,7 +647,7 @@ int vfs_make_vfs_path(const char* path, char* vfs_path)
|
||||
// used by vfs_realpath and VFile_reopen.
|
||||
static int make_file_path(char* path, const char* vfs_path, const TMountPoint* mount_point)
|
||||
{
|
||||
assert(mount_point->archive == 0);
|
||||
debug_assert(mount_point->archive == 0);
|
||||
|
||||
const char* remove = mount_point->v_mount_point.c_str();
|
||||
const char* replace = mount_point->p_real_path.c_str();
|
||||
@ -925,14 +925,14 @@ H_TYPE_DEFINE(VFile);
|
||||
|
||||
static off_t& vf_size(VFile* vf)
|
||||
{
|
||||
assert(offsetof(struct File, size) == offsetof(struct ZFile, ucsize));
|
||||
debug_assert(offsetof(struct File, size) == offsetof(struct ZFile, ucsize));
|
||||
return vf->f.size;
|
||||
}
|
||||
|
||||
|
||||
static uint& vf_flags(VFile* vf)
|
||||
{
|
||||
assert(offsetof(struct File, flags) == offsetof(struct ZFile, flags));
|
||||
debug_assert(offsetof(struct File, flags) == offsetof(struct ZFile, flags));
|
||||
return vf->f.flags;
|
||||
}
|
||||
|
||||
@ -1179,7 +1179,7 @@ debug_printf("vfs_load v_fn=%s\n", v_fn);
|
||||
p = mem_get_ptr(vf->hm, &size);
|
||||
if(p)
|
||||
{
|
||||
assert(vf_size(vf) == (off_t)size && "vfs_load: mismatch between File and Mem size");
|
||||
debug_assert(vf_size(vf) == (off_t)size && "vfs_load: mismatch between File and Mem size");
|
||||
hm = vf->hm;
|
||||
goto ret;
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ int TDir::lookup(const char* path, uint flags, TNode** pnode, char* exact_path)
|
||||
}
|
||||
|
||||
CHECK_PATH(path);
|
||||
assert( (flags & ~(LF_CREATE_MISSING|LF_START_DIR)) == 0 );
|
||||
debug_assert( (flags & ~(LF_CREATE_MISSING|LF_START_DIR)) == 0 );
|
||||
// no undefined bits set
|
||||
|
||||
const bool create_missing = !!(flags & LF_CREATE_MISSING);
|
||||
@ -716,7 +716,7 @@ struct NodeLatch
|
||||
|
||||
const TNode* get_next()
|
||||
{
|
||||
assert(!empty());
|
||||
debug_assert(!empty());
|
||||
return v[i++];
|
||||
}
|
||||
};
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
// provision for removing all ZLib code (all inflate calls will fail).
|
||||
@ -209,7 +209,7 @@ static time_t convert_dos_date(u16 fatdate, u16 fattime)
|
||||
t.tm_year = bits(fatdate, 9,15) + 80; // since 1900
|
||||
t.tm_isdst = -1; // unknown - let libc determine
|
||||
|
||||
assert(t.tm_year < 138);
|
||||
debug_assert(t.tm_year < 138);
|
||||
// otherwise: totally bogus, and at the limit of 32-bit time_t
|
||||
|
||||
time_t ret = mktime(&t);
|
||||
@ -462,7 +462,7 @@ static int lookup_add_file_cb(uintptr_t user, i32 idx,
|
||||
|
||||
// adding a regular file.
|
||||
|
||||
assert(idx < li->num_entries);
|
||||
debug_assert(idx < li->num_entries);
|
||||
FnHash fn_hash = fnv_lc_hash(fn, fn_len);
|
||||
|
||||
// fill ZEnt
|
||||
@ -553,7 +553,7 @@ static int lookup_get_file_info(LookupInfo* li, const char* fn, ZLoc* loc)
|
||||
return ERR_FILE_NOT_FOUND;
|
||||
|
||||
i = it->second;
|
||||
assert(0 <= i && i < li->num_files);
|
||||
debug_assert(0 <= i && i < li->num_files);
|
||||
}
|
||||
|
||||
have_idx:
|
||||
@ -842,7 +842,7 @@ total_inf_time += t1-t0;
|
||||
// which doesn't abort the read.
|
||||
size_t avail_out = zs->avail_out;
|
||||
|
||||
assert(avail_out <= prev_avail_out);
|
||||
debug_assert(avail_out <= prev_avail_out);
|
||||
// make sure output buffer size didn't magically increase
|
||||
ssize_t nread = (ssize_t)(prev_avail_out - avail_out);
|
||||
if(!nread)
|
||||
|
@ -62,7 +62,7 @@
|
||||
#define ENFORCE(condition, retval) STMT(\
|
||||
if(!(condition)) \
|
||||
{ \
|
||||
assert2(condition); \
|
||||
debug_assert(condition); \
|
||||
return retval; \
|
||||
} \
|
||||
)
|
||||
@ -88,7 +88,7 @@
|
||||
size_t tlen_s(const tchar* str, size_t max_len)
|
||||
{
|
||||
// note: we can't bail - what would the return value be?
|
||||
assert2(str != 0);
|
||||
debug_assert(str != 0);
|
||||
|
||||
WARN_IF_PTR_LEN(max_len);
|
||||
|
||||
@ -234,53 +234,53 @@ static tchar no_null[] = { 'n','o','_','n','u','l','l'};
|
||||
|
||||
#define TEST_LEN(string, limit, expected) \
|
||||
STMT( \
|
||||
assert2(tlen_s((string), (limit)) == (expected)); \
|
||||
debug_assert(tlen_s((string), (limit)) == (expected)); \
|
||||
)
|
||||
|
||||
#define TEST_CPY(dst, dst_max, src, expected_ret, expected_dst) \
|
||||
STMT( \
|
||||
int ret = tcpy_s((dst), dst_max, (src)); \
|
||||
assert2(ret == expected_ret); \
|
||||
debug_assert(ret == expected_ret); \
|
||||
if(dst != 0) \
|
||||
assert2(!tcmp(dst, T(expected_dst))); \
|
||||
debug_assert(!tcmp(dst, T(expected_dst))); \
|
||||
)
|
||||
#define TEST_CPY2(dst, src, expected_ret, expected_dst) \
|
||||
STMT( \
|
||||
int ret = tcpy_s((dst), ARRAY_SIZE(dst), (src)); \
|
||||
assert2(ret == expected_ret); \
|
||||
debug_assert(ret == expected_ret); \
|
||||
if(dst != 0) \
|
||||
assert2(!tcmp(dst, T(expected_dst))); \
|
||||
debug_assert(!tcmp(dst, T(expected_dst))); \
|
||||
)
|
||||
#define TEST_NCPY(dst, src, max_src_chars, expected_ret, expected_dst) \
|
||||
STMT( \
|
||||
int ret = tncpy_s((dst), ARRAY_SIZE(dst), (src), (max_src_chars)); \
|
||||
assert2(ret == expected_ret); \
|
||||
debug_assert(ret == expected_ret); \
|
||||
if(dst != 0) \
|
||||
assert2(!tcmp(dst, T(expected_dst))); \
|
||||
debug_assert(!tcmp(dst, T(expected_dst))); \
|
||||
)
|
||||
|
||||
#define TEST_CAT(dst, dst_max, src, expected_ret, expected_dst) \
|
||||
STMT( \
|
||||
int ret = tcat_s((dst), dst_max, (src)); \
|
||||
assert2(ret == expected_ret); \
|
||||
debug_assert(ret == expected_ret); \
|
||||
if(dst != 0) \
|
||||
assert2(!tcmp(dst, T(expected_dst))); \
|
||||
debug_assert(!tcmp(dst, T(expected_dst))); \
|
||||
)
|
||||
#define TEST_CAT2(dst, dst_val, src, expected_ret, expected_dst) \
|
||||
STMT( \
|
||||
tcpy(dst, T(dst_val)); \
|
||||
int ret = tcat_s((dst), ARRAY_SIZE(dst), (src)); \
|
||||
assert2(ret == expected_ret); \
|
||||
debug_assert(ret == expected_ret); \
|
||||
if(dst != 0) \
|
||||
assert2(!tcmp(dst, T(expected_dst))); \
|
||||
debug_assert(!tcmp(dst, T(expected_dst))); \
|
||||
)
|
||||
#define TEST_NCAT(dst, dst_val, src, max_src_chars, expected_ret, expected_dst)\
|
||||
STMT( \
|
||||
tcpy(dst, T(dst_val)); \
|
||||
int ret = tncat_s((dst), ARRAY_SIZE(dst), (src), (max_src_chars)); \
|
||||
assert2(ret == expected_ret); \
|
||||
debug_assert(ret == expected_ret); \
|
||||
if(dst != 0) \
|
||||
assert2(!tcmp(dst, T(expected_dst))); \
|
||||
debug_assert(!tcmp(dst, T(expected_dst))); \
|
||||
)
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "win/wtime.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -454,7 +454,7 @@ int get_cur_processor_id()
|
||||
// called on each CPU by on_each_cpu.
|
||||
static void check_smp()
|
||||
{
|
||||
assert(cpus > 0 && "must know # CPUs (call OS-specific detect first)");
|
||||
debug_assert(cpus > 0 && "must know # CPUs (call OS-specific detect first)");
|
||||
|
||||
// we don't check if it's Intel and P4 or above - HT may be supported
|
||||
// on other CPUs in future. haven't come across a processor that
|
||||
@ -566,7 +566,7 @@ __declspec(naked) bool __cdecl CAS_(uintptr_t* location, uintptr_t expected, uin
|
||||
{
|
||||
// try to see if caller isn't passing in an address
|
||||
// (CAS's arguments are silently casted)
|
||||
assert2(location >= (uintptr_t*)0x10000);
|
||||
debug_assert(location >= (uintptr_t*)0x10000);
|
||||
|
||||
__asm
|
||||
{
|
||||
@ -621,7 +621,7 @@ bool CAS_(uintptr_t* location, uintptr_t expected, uintptr_t new_value)
|
||||
{
|
||||
uintptr_t prev;
|
||||
|
||||
assert2(location >= (uintptr_t *)0x10000);
|
||||
debug_assert(location >= (uintptr_t *)0x10000);
|
||||
|
||||
__asm__ __volatile__("lock; cmpxchgl %1,%2"
|
||||
: "=a"(prev) // %0: Result in eax should be stored in prev
|
||||
|
@ -30,7 +30,7 @@ enum DisplayErrorFlags
|
||||
DE_MANUAL_BREAK = 4
|
||||
};
|
||||
|
||||
// user choices in the assert/unhandled exception dialog.
|
||||
// user choices in the debug_assert/unhandled exception dialog.
|
||||
enum ErrorReaction
|
||||
{
|
||||
// ignore, continue as if nothing happened.
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <tchar.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
@ -271,7 +271,7 @@ extern "C" int vsnprintf2(TCHAR* buffer, size_t count, const TCHAR* format, va_l
|
||||
|
||||
if (chr == _T('I'))
|
||||
{
|
||||
assert(! "MSVC-style \"%I64\" is not allowed!");
|
||||
debug_assert(! "MSVC-style \"%I64\" is not allowed!");
|
||||
}
|
||||
|
||||
if (is_lengthmod(chr))
|
||||
@ -420,7 +420,7 @@ finished_reading:
|
||||
{
|
||||
if (varsizes[i] <= 0)
|
||||
{
|
||||
assert(! "Invalid variable type somewhere - make sure all variable things are positional and defined");
|
||||
debug_assert(! "Invalid variable type somewhere - make sure all variable things are positional and defined");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -442,7 +442,7 @@ finished_reading:
|
||||
FormatVariable* s = static_cast<FormatVariable*>(*it);
|
||||
if (s->position <= 0)
|
||||
{
|
||||
assert(! "Invalid use of positional elements - make sure all variable things are positional and defined");
|
||||
debug_assert(! "Invalid use of positional elements - make sure all variable things are positional and defined");
|
||||
return -1;
|
||||
}
|
||||
newstack += std::string( stackitems[s->position-1].first, stackitems[s->position-1].second );
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "posix.h"
|
||||
#include "win_internal.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h> // _aligned_malloc
|
||||
|
||||
@ -304,7 +304,7 @@ static void req_cleanup(void)
|
||||
for(int i = 0; i < MAX_REQS; i++, r++)
|
||||
{
|
||||
HANDLE& h = r->ovl.hEvent;
|
||||
assert(h != INVALID_HANDLE_VALUE);
|
||||
debug_assert(h != INVALID_HANDLE_VALUE);
|
||||
CloseHandle(h);
|
||||
h = INVALID_HANDLE_VALUE;
|
||||
|
||||
@ -339,7 +339,7 @@ static Req* req_find(const aiocb* cb)
|
||||
|
||||
static Req* req_alloc(aiocb* cb)
|
||||
{
|
||||
assert(cb);
|
||||
debug_assert(cb);
|
||||
|
||||
// first free Req, or 0
|
||||
Req* r = req_find(0);
|
||||
@ -353,7 +353,7 @@ static Req* req_alloc(aiocb* cb)
|
||||
|
||||
static int req_free(Req* r)
|
||||
{
|
||||
assert(r->cb != 0 && "req_free: not currently in use");
|
||||
debug_assert(r->cb != 0 && "req_free: not currently in use");
|
||||
r->cb = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -390,7 +390,7 @@ static int aio_rw(struct aiocb* cb)
|
||||
const size_t size = cb->aio_nbytes;
|
||||
const off_t ofs = cb->aio_offset;
|
||||
void* buf = (void*)cb->aio_buf; // from volatile void*
|
||||
assert(buf);
|
||||
debug_assert(buf);
|
||||
|
||||
// allocate IO request
|
||||
r = req_alloc(cb);
|
||||
@ -566,7 +566,7 @@ ssize_t aio_return(struct aiocb* cb)
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(r->ovl.Internal == 0 && "aio_return with transfer in progress");
|
||||
debug_assert(r->ovl.Internal == 0 && "aio_return with transfer in progress");
|
||||
|
||||
const BOOL wait = FALSE; // should already be done!
|
||||
DWORD bytes_transferred;
|
||||
@ -738,7 +738,7 @@ static int waio_init()
|
||||
|
||||
SetErrorMode(old_err_mode);
|
||||
|
||||
assert(is_pow2((long)sector_size));
|
||||
debug_assert(is_pow2((long)sector_size));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ static uintptr_t get_target_pc()
|
||||
/////////////////////////////////////////////
|
||||
|
||||
ret = ResumeThread(hThread);
|
||||
assert(ret != 0);
|
||||
debug_assert(ret != 0);
|
||||
// don't fail (we have a valid PC), but warn
|
||||
|
||||
return pc;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "win_internal.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -429,7 +429,7 @@ static void add_oal_dlls_in_dir(const char* dir, DllSet* dlls)
|
||||
const int len = snprintf(path, MAX_PATH, "%s\\", dir);
|
||||
if(len < 0)
|
||||
{
|
||||
assert(0);
|
||||
debug_assert(0);
|
||||
return;
|
||||
}
|
||||
PathInfo pi = { path, path+len, MAX_PATH-len, dlls };
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "win_internal.h"
|
||||
#include "lib/res/file.h" // file_is_subpath
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
@ -240,7 +240,7 @@ int dir_add_watch(const char* dir, intptr_t* _reqnum)
|
||||
try
|
||||
{
|
||||
Watch* w = new Watch(reqnum, dir_s, hDir);
|
||||
assert(w != 0); // happened once; heap corruption?
|
||||
debug_assert(w != 0); // happened once; heap corruption?
|
||||
|
||||
// add trailing \ if not already there
|
||||
if(dir_s[dir_s.length()-1] != '\\')
|
||||
@ -285,7 +285,7 @@ int dir_cancel_watch(const intptr_t reqnum)
|
||||
}
|
||||
|
||||
// we're freeing a reference - done.
|
||||
assert(w->refs >= 1);
|
||||
debug_assert(w->refs >= 1);
|
||||
if(--w->refs != 0)
|
||||
return 0;
|
||||
|
||||
@ -304,7 +304,7 @@ int dir_cancel_watch(const intptr_t reqnum)
|
||||
|
||||
static int extract_events(Watch* w)
|
||||
{
|
||||
assert(w);
|
||||
debug_assert(w);
|
||||
|
||||
// points to current FILE_NOTIFY_INFORMATION;
|
||||
// char* simplifies advancing to the next (variable length) FNI.
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "posix.h"
|
||||
#include "win_internal.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -113,7 +113,7 @@ int close(int fd)
|
||||
debug_printf("close %d\n", fd);
|
||||
#endif
|
||||
|
||||
assert(3 <= fd && fd < 256);
|
||||
debug_assert(3 <= fd && fd < 256);
|
||||
|
||||
// note: there's no good way to notify us that <fd> wasn't opened for
|
||||
// AIO, so we could skip aio_close. storing a bit in the fd is evil and
|
||||
@ -214,13 +214,13 @@ static void detect_filesystem()
|
||||
{
|
||||
char root_path[MAX_PATH] = "c:\\"; // default in case GCD fails
|
||||
DWORD gcd_ret = GetCurrentDirectory(sizeof(root_path), root_path);
|
||||
assert2(gcd_ret != 0);
|
||||
debug_assert(gcd_ret != 0);
|
||||
// if this fails, no problem - we have the default from above.
|
||||
root_path[3] = '\0'; // cut off after "c:\"
|
||||
|
||||
char fs_name[32];
|
||||
BOOL ret = GetVolumeInformation(root_path, 0,0,0,0,0, fs_name, sizeof(fs_name));
|
||||
assert2(ret != 0);
|
||||
debug_assert(ret != 0);
|
||||
// if this fails, no problem - we really only care if fs is FAT,
|
||||
// and will assume that's not the case (since fs_name != "FAT").
|
||||
|
||||
@ -525,7 +525,7 @@ void* mmap(void* user_start, size_t len, int prot, int flags, int fd, off_t offs
|
||||
if(flags & MAP_FIXED)
|
||||
{
|
||||
start = user_start;
|
||||
if(start == 0) // assert below would fire
|
||||
if(start == 0) // debug_assert below would fire
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ void* mmap(void* user_start, size_t len, int prot, int flags, int fd, off_t offs
|
||||
// but after freeing the mapping object.
|
||||
goto fail;
|
||||
|
||||
assert(!(flags & MAP_FIXED) || (ptr == start));
|
||||
debug_assert(!(flags & MAP_FIXED) || (ptr == start));
|
||||
// fixed => ptr = start
|
||||
|
||||
WIN_RESTORE_LAST_ERROR;
|
||||
|
@ -125,7 +125,7 @@ int pthread_key_create(pthread_key_t* key, void (*dtor)(void*))
|
||||
if(idx == TLS_OUT_OF_INDEXES)
|
||||
return -ENOMEM;
|
||||
|
||||
assert2(idx < TLS_LIMIT);
|
||||
debug_assert(idx < TLS_LIMIT);
|
||||
*key = (pthread_key_t)idx;
|
||||
|
||||
// store dtor
|
||||
@ -146,10 +146,10 @@ int pthread_key_create(pthread_key_t* key, void (*dtor)(void*))
|
||||
int pthread_key_delete(pthread_key_t key)
|
||||
{
|
||||
DWORD idx = (DWORD)key;
|
||||
assert2(idx < TLS_LIMIT);
|
||||
debug_assert(idx < TLS_LIMIT);
|
||||
|
||||
BOOL ret = TlsFree(idx);
|
||||
assert2(ret != 0);
|
||||
debug_assert(ret != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ int pthread_key_delete(pthread_key_t key)
|
||||
void* pthread_getspecific(pthread_key_t key)
|
||||
{
|
||||
DWORD idx = (DWORD)key;
|
||||
assert2(idx < TLS_LIMIT);
|
||||
debug_assert(idx < TLS_LIMIT);
|
||||
|
||||
// TlsGetValue sets last error to 0 on success (boo).
|
||||
// we don't want this to hide previous errors, so it's restored below.
|
||||
@ -183,10 +183,10 @@ void* pthread_getspecific(pthread_key_t key)
|
||||
int pthread_setspecific(pthread_key_t key, const void* value)
|
||||
{
|
||||
DWORD idx = (DWORD)key;
|
||||
assert2(idx < TLS_LIMIT);
|
||||
debug_assert(idx < TLS_LIMIT);
|
||||
|
||||
BOOL ret = TlsSetValue(idx, (void*)value);
|
||||
assert2(ret != 0);
|
||||
debug_assert(ret != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ again:
|
||||
if(tls)
|
||||
{
|
||||
int ret = pthread_setspecific(key, 0);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
|
||||
dtor(tls);
|
||||
had_valid_tls = true;
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include <ddraw.h>
|
||||
#include <process.h> // _beginthreadex
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
@ -271,7 +271,7 @@ inline SDLKey vkmap(int vk)
|
||||
|
||||
ONCE( init_vkmap(VK_SDLKMap); );
|
||||
|
||||
assert(vk >= 0 && vk < 256);
|
||||
debug_assert(vk >= 0 && vk < 256);
|
||||
|
||||
return VK_SDLKMap[vk];
|
||||
}
|
||||
@ -279,7 +279,7 @@ inline SDLKey vkmap(int vk)
|
||||
|
||||
int SDL_WaitEvent(SDL_Event* ev)
|
||||
{
|
||||
assert(ev == 0 && "can't store event, since wsdl doesn't have a real queue");
|
||||
debug_assert(ev == 0 && "can't store event, since wsdl doesn't have a real queue");
|
||||
WaitMessage();
|
||||
return 0;
|
||||
}
|
||||
@ -299,7 +299,7 @@ int SDL_PollEvent(SDL_Event* ev)
|
||||
|
||||
// input is waiting in buffer
|
||||
return_char:
|
||||
assert(num_chars <= CHAR_BUF_SIZE);
|
||||
debug_assert(num_chars <= CHAR_BUF_SIZE);
|
||||
if(num_chars > 0)
|
||||
{
|
||||
num_chars--;
|
||||
@ -387,7 +387,7 @@ return_char:
|
||||
default:
|
||||
if( ( msg.message >= WM_APP ) && ( msg.message < 0xC000 ) ) // 0xC000 = maximum application message
|
||||
{
|
||||
assert( SDL_USEREVENT+(msg.message-WM_APP) <= 0xff && "Message too far above WM_APP");
|
||||
debug_assert( SDL_USEREVENT+(msg.message-WM_APP) <= 0xff && "Message too far above WM_APP");
|
||||
ev->type = (u8)(SDL_USEREVENT+(msg.message-WM_APP));
|
||||
ev->user.code = (int)msg.wParam;
|
||||
return 1;
|
||||
@ -506,13 +506,13 @@ static void enable_kbd_hook(bool enable)
|
||||
/*
|
||||
if(enable)
|
||||
{
|
||||
assert(hKeyboard_LL_Hook == 0);
|
||||
debug_assert(hKeyboard_LL_Hook == 0);
|
||||
hKeyboard_LL_Hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_ll_hook, hInst, 0);
|
||||
assert(hKeyboard_LL_Hook != 0);
|
||||
debug_assert(hKeyboard_LL_Hook != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(hKeyboard_LL_Hook != 0);
|
||||
debug_assert(hKeyboard_LL_Hook != 0);
|
||||
UnhookWindowsHookEx(hKeyboard_LL_Hook);
|
||||
hKeyboard_LL_Hook = 0;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "wsock.h"
|
||||
#include "wdll.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
|
@ -306,7 +306,7 @@ static i64 ticks_lk()
|
||||
{
|
||||
LARGE_INTEGER i;
|
||||
BOOL ok = QueryPerformanceCounter(&i);
|
||||
assert(ok); // shouldn't fail if it was chosen above
|
||||
debug_assert(ok); // shouldn't fail if it was chosen above
|
||||
return i.QuadPart;
|
||||
}
|
||||
#endif
|
||||
@ -336,8 +336,8 @@ static i64 ticks_lk()
|
||||
// (not a problem, but avoids a BoundsChecker warning)
|
||||
static double time_lk()
|
||||
{
|
||||
assert(hrt_cur_freq > 0.0);
|
||||
assert(hrt_cal_ticks > 0);
|
||||
debug_assert(hrt_cur_freq > 0.0);
|
||||
debug_assert(hrt_cal_ticks > 0);
|
||||
|
||||
// elapsed ticks and time since last calibration
|
||||
const i64 delta_ticks = ticks_lk() - hrt_cal_ticks;
|
||||
@ -381,7 +381,7 @@ static int reset_impl_lk()
|
||||
old_time = time_lk();
|
||||
|
||||
CHECK_ERR(choose_impl());
|
||||
assert(hrt_impl != HRT_NONE && hrt_nominal_freq > 0.0);
|
||||
debug_assert(hrt_impl != HRT_NONE && hrt_nominal_freq > 0.0);
|
||||
|
||||
// impl has changed; reset timer state.
|
||||
if(old_impl != hrt_impl)
|
||||
@ -427,7 +427,7 @@ lock();
|
||||
double freq = hrt_cur_freq;
|
||||
unlock();
|
||||
|
||||
assert(freq != -1.0 && "hrt_delta_s: hrt_cur_freq not set");
|
||||
debug_assert(freq != -1.0 && "hrt_delta_s: hrt_cur_freq not set");
|
||||
return (end - start) / freq;
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ lock();
|
||||
|
||||
unlock();
|
||||
|
||||
assert(nominal_freq > 0.0 && "hrt_query_impl: invalid hrt_nominal_freq");
|
||||
debug_assert(nominal_freq > 0.0 && "hrt_query_impl: invalid hrt_nominal_freq");
|
||||
}
|
||||
|
||||
|
||||
@ -502,7 +502,7 @@ static long safe_time()
|
||||
// lock must be held.
|
||||
static void calibrate_lk()
|
||||
{
|
||||
assert(hrt_cal_ticks > 0);
|
||||
debug_assert(hrt_cal_ticks > 0);
|
||||
|
||||
// we're called from a WinMM event or after thread wakeup,
|
||||
// so the timer has just been updated.
|
||||
@ -547,7 +547,7 @@ static void calibrate_lk()
|
||||
hrt_cur_freq = hrt_nominal_freq;
|
||||
}
|
||||
|
||||
assert(hrt_cur_freq > 0.0);
|
||||
debug_assert(hrt_cur_freq > 0.0);
|
||||
}
|
||||
|
||||
|
||||
@ -775,7 +775,7 @@ static void sleep_ns(i64 ns)
|
||||
|
||||
int clock_gettime(clockid_t clock, struct timespec* t)
|
||||
{
|
||||
assert(clock == CLOCK_REALTIME);
|
||||
debug_assert(clock == CLOCK_REALTIME);
|
||||
|
||||
const i64 ns = time_ns();
|
||||
t->tv_sec = (time_t)((ns / _1e9) & 0xffffffff);
|
||||
@ -786,7 +786,7 @@ int clock_gettime(clockid_t clock, struct timespec* t)
|
||||
|
||||
int clock_getres(clockid_t clock, struct timespec* ts)
|
||||
{
|
||||
assert(clock == CLOCK_REALTIME);
|
||||
debug_assert(clock == CLOCK_REALTIME);
|
||||
|
||||
HRTImpl impl;
|
||||
double nominal_freq, res;
|
||||
|
@ -681,7 +681,7 @@ static void LoadGlobals()
|
||||
float gain;
|
||||
val->GetFloat(gain);
|
||||
int ret = snd_set_master_gain(gain);
|
||||
assert2(ret == 0);
|
||||
debug_assert(ret == 0);
|
||||
}
|
||||
|
||||
LOG(NORMAL, LOG_CATEGORY, "g_x/yres is %dx%d", g_xres, g_yres);
|
||||
@ -1374,7 +1374,7 @@ static void Frame()
|
||||
last_time = time;
|
||||
ONCE(return);
|
||||
// first call: set last_time and return
|
||||
assert(TimeSinceLastFrame >= 0.0f);
|
||||
debug_assert(TimeSinceLastFrame >= 0.0f);
|
||||
|
||||
PROFILE_START( "reload changed files" );
|
||||
MICROLOG(L"reload files");
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
// necessary includes
|
||||
#include <assert.h>
|
||||
|
||||
#include <float.h>
|
||||
#include "Bound.h"
|
||||
|
||||
@ -147,7 +147,7 @@ bool CBound::IsEmpty()
|
||||
// (can't remember which one it was, though)
|
||||
void CBound::Transform(const CMatrix3D& m,CBound& result) const
|
||||
{
|
||||
assert(this!=&result);
|
||||
debug_assert(this!=&result);
|
||||
|
||||
for (int i=0;i<3;++i) {
|
||||
// handle translation
|
||||
|
@ -473,7 +473,7 @@ void CConsole::ProcessBuffer(const wchar_t* szLine){
|
||||
if (szLine == NULL) return;
|
||||
if (wcslen(szLine) <= 0) return;
|
||||
|
||||
assert(wcslen(szLine) < CONSOLE_BUFFER_SIZE);
|
||||
debug_assert(wcslen(szLine) < CONSOLE_BUFFER_SIZE);
|
||||
|
||||
m_deqBufHistory.push_front(szLine);
|
||||
SaveHistory(); // Do this each line for the moment; if a script causes
|
||||
|
@ -309,14 +309,14 @@ CStr CStr::UCase() const
|
||||
// Retrieve the substring of the first n characters
|
||||
CStr CStr::Left(size_t len) const
|
||||
{
|
||||
assert(len <= length());
|
||||
debug_assert(len <= length());
|
||||
return substr(0, len);
|
||||
}
|
||||
|
||||
// Retrieve the substring of the last n characters
|
||||
CStr CStr::Right(size_t len) const
|
||||
{
|
||||
assert(len <= length());
|
||||
debug_assert(len <= length());
|
||||
return substr(length()-len, len);
|
||||
}
|
||||
|
||||
|
@ -212,8 +212,8 @@ public:
|
||||
operator const tchar*() const;
|
||||
|
||||
// Do some range checking in debug builds
|
||||
tchar &operator[](size_t n) { assert(n < length()); return this->std::tstring::operator[](n); }
|
||||
tchar &operator[](int n) { assert(n >= 0 && (size_t)n < length()); return this->std::tstring::operator[](n); }
|
||||
tchar &operator[](size_t n) { debug_assert(n < length()); return this->std::tstring::operator[](n); }
|
||||
tchar &operator[](int n) { debug_assert(n >= 0 && (size_t)n < length()); return this->std::tstring::operator[](n); }
|
||||
|
||||
// Conversion to utf16string
|
||||
inline utf16string utf16() const
|
||||
|
@ -170,9 +170,9 @@ namespace ConfigDB_JS
|
||||
int flags=JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT;
|
||||
#define cfg_ns(_propname, _enum) STMT (\
|
||||
JSObject *nsobj=g_ScriptingHost.CreateCustomObject("ConfigNamespace"); \
|
||||
assert(nsobj); \
|
||||
debug_assert(nsobj); \
|
||||
ConfigNamespace_JS::SetNamespace(cx, nsobj, _enum); \
|
||||
assert(JS_DefineProperty(cx, newObj, _propname, OBJECT_TO_JSVAL(nsobj), NULL, NULL, flags)); )
|
||||
debug_assert(JS_DefineProperty(cx, newObj, _propname, OBJECT_TO_JSVAL(nsobj), NULL, NULL, flags)); )
|
||||
|
||||
cfg_ns("system", CFG_SYSTEM);
|
||||
cfg_ns("user", CFG_USER);
|
||||
@ -202,7 +202,7 @@ CConfigValue *CConfigDB::GetValue(EConfigNamespace ns, CStr name)
|
||||
|
||||
CConfigValueSet *CConfigDB::GetValues(EConfigNamespace ns, CStr name )
|
||||
{
|
||||
assert(ns < CFG_LAST && ns >= 0);
|
||||
debug_assert(ns < CFG_LAST && ns >= 0);
|
||||
|
||||
TConfigMap::iterator it = m_Map[CFG_COMMAND].find( name );
|
||||
if( it != m_Map[CFG_COMMAND].end() )
|
||||
@ -220,7 +220,7 @@ CConfigValueSet *CConfigDB::GetValues(EConfigNamespace ns, CStr name )
|
||||
|
||||
CConfigValue *CConfigDB::CreateValue(EConfigNamespace ns, CStr name)
|
||||
{
|
||||
assert(ns < CFG_LAST && ns >= 0);
|
||||
debug_assert(ns < CFG_LAST && ns >= 0);
|
||||
|
||||
CConfigValue *ret=GetValue(ns, name);
|
||||
if (ret) return ret;
|
||||
@ -231,7 +231,7 @@ CConfigValue *CConfigDB::CreateValue(EConfigNamespace ns, CStr name)
|
||||
|
||||
void CConfigDB::SetConfigFile(EConfigNamespace ns, bool useVFS, CStr path)
|
||||
{
|
||||
assert(ns < CFG_LAST && ns >= 0);
|
||||
debug_assert(ns < CFG_LAST && ns >= 0);
|
||||
|
||||
m_ConfigFile[ns]=path;
|
||||
m_UseVFS[ns]=useVFS;
|
||||
@ -336,7 +336,7 @@ bool CConfigDB::Reload(EConfigNamespace ns)
|
||||
|
||||
bool CConfigDB::WriteFile(EConfigNamespace ns, bool useVFS, CStr path)
|
||||
{
|
||||
assert(ns >= 0 && ns < CFG_LAST);
|
||||
debug_assert(ns >= 0 && ns < CFG_LAST);
|
||||
|
||||
char realpath[VFS_MAX_PATH];
|
||||
char nativepath[VFS_MAX_PATH];
|
||||
|
@ -69,7 +69,7 @@ PSRETURN CGame::ReallyStartGame()
|
||||
// Call the reallyStartGame function, but only if it exists
|
||||
jsval fval, rval;
|
||||
JSBool ok = JS_GetProperty(g_ScriptingHost.getContext(), g_GUI.GetScriptObject(), "reallyStartGame", &fval);
|
||||
assert(ok);
|
||||
debug_assert(ok);
|
||||
if (ok && !JSVAL_IS_VOID(fval))
|
||||
{
|
||||
ok = JS_CallFunctionValue(g_ScriptingHost.getContext(), g_GUI.GetScriptObject(), fval, 0, NULL, &rval);
|
||||
@ -139,7 +139,7 @@ CPlayer *CGame::GetPlayer(uint idx)
|
||||
if (m_Players.size() == 0)
|
||||
{
|
||||
// Hmm. This is a bit of a problem.
|
||||
assert2(! "### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###");
|
||||
debug_assert(! "### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###");
|
||||
abort();
|
||||
return NULL; // else VC2005 warns about not returning a value
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ int hotkeyInputHandler( const SDL_Event* ev )
|
||||
int keyCode = *itKey & ~HOTKEY_NEGATION_FLAG; // Clear the negation-modifier bit
|
||||
bool rqdState = !( *itKey & HOTKEY_NEGATION_FLAG );
|
||||
|
||||
// assert( !rqdState );
|
||||
// debug_assert( !rqdState );
|
||||
|
||||
if( keyCode < SDLK_LAST )
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ bool customSelectionMode=false;
|
||||
void CSelectedEntities::addSelection( HEntity entity )
|
||||
{
|
||||
m_group = -1;
|
||||
assert( !isSelected( entity ) );
|
||||
debug_assert( !isSelected( entity ) );
|
||||
m_selected.push_back( entity );
|
||||
entity->m_selected = true;
|
||||
m_selectionChanged = true;
|
||||
@ -39,7 +39,7 @@ void CSelectedEntities::addSelection( HEntity entity )
|
||||
void CSelectedEntities::removeSelection( HEntity entity )
|
||||
{
|
||||
m_group = -1;
|
||||
assert( isSelected( entity ) );
|
||||
debug_assert( isSelected( entity ) );
|
||||
entity->m_selected = false;
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
|
@ -285,7 +285,7 @@ int LDR_ProgressiveLoad(double time_budget, wchar_t* description,
|
||||
// set output params (there are several return points above)
|
||||
done:
|
||||
*progress_percent = (int)(progress * 100.0);
|
||||
assert2(0 <= *progress_percent && *progress_percent <= 100);
|
||||
debug_assert(0 <= *progress_percent && *progress_percent <= 100);
|
||||
|
||||
// we want the next task, instead of what just completed:
|
||||
// it will be displayed during the next load phase.
|
||||
|
@ -164,7 +164,7 @@ extern int LDR_NonprogressiveLoad();
|
||||
/* 0 means "finished", so don't return that! */\
|
||||
if(progress_percent == 0)\
|
||||
progress_percent = 1;\
|
||||
assert2(0 < progress_percent && progress_percent <= 100);\
|
||||
debug_assert(0 < progress_percent && progress_percent <= 100);\
|
||||
return progress_percent;\
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
const char* name() const { return (const char*) _name; }
|
||||
|
||||
// accessors for font metrics
|
||||
int width(int c) const { assert(c>=0 && c<128); return _chars[c]._width; }
|
||||
int width(int c) const { debug_assert(c>=0 && c<128); return _chars[c]._width; }
|
||||
int height() const { return _metrics._height; }
|
||||
int descent() const { return _metrics._descent; }
|
||||
int maxcharwidth() const { return _metrics._maxcharwidth; }
|
||||
@ -43,7 +43,7 @@ public:
|
||||
|
||||
// accessor for character data
|
||||
const CharData& chardata(char c) const {
|
||||
assert( !(c&0x80) ); // only allow 7-bit ASCII
|
||||
debug_assert( !(c&0x80) ); // only allow 7-bit ASCII
|
||||
return _chars[c];
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ bool NPFontManager::remove(const char* name)
|
||||
} else {
|
||||
typedef std::vector<NPFont*>::iterator Iter;
|
||||
Iter iter=std::find(_fonts.begin(),_fonts.end(),font);
|
||||
assert(iter != _fonts.end());
|
||||
debug_assert(iter != _fonts.end());
|
||||
_fonts.erase(iter);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void CNetMessage::ScriptingInit()
|
||||
|
||||
CNetCommand *CNetMessage::CommandFromJSArgs(const CEntityList &entities, JSContext *cx, uintN argc, jsval *argv)
|
||||
{
|
||||
assert(argc >= 1);
|
||||
debug_assert(argc >= 1);
|
||||
|
||||
int msgType;
|
||||
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
*/
|
||||
inline IMessagePipeEnd &GetEnd(int idx)
|
||||
{
|
||||
assert(idx==1 || idx==0);
|
||||
debug_assert(idx==1 || idx==0);
|
||||
return m_Ends[idx];
|
||||
}
|
||||
};
|
||||
|
@ -288,7 +288,7 @@ void CSocketBase::Destroy()
|
||||
|
||||
// Remove any data associated with the file descriptor
|
||||
GLOBAL_LOCK();
|
||||
assert2(g_SocketSetInternal.m_NumSockets > 0);
|
||||
debug_assert(g_SocketSetInternal.m_NumSockets > 0);
|
||||
|
||||
g_SocketSetInternal.m_NumSockets--;
|
||||
g_SocketSetInternal.m_HandleMap.erase(m_pInternal->m_fd);
|
||||
|
@ -889,7 +889,7 @@ next [a] Null [a] <-- added NewNode
|
||||
}
|
||||
|
||||
// Dive into the alternative node
|
||||
assert(! CurNode->m_AltNode);
|
||||
debug_assert(! CurNode->m_AltNode);
|
||||
CurNode->m_AltNode = new CParserTaskTypeNode();
|
||||
CurNode->m_AltNode->m_ParentNode = CurNode;
|
||||
|
||||
@ -934,7 +934,7 @@ next [a] Null [a] <-- added NewNode
|
||||
{
|
||||
// Check if this is the first input
|
||||
// CONSTRUCT A CHILD NODE
|
||||
assert(! CurNode->m_NextNode);
|
||||
debug_assert(! CurNode->m_NextNode);
|
||||
CurNode->m_NextNode = new CParserTaskTypeNode();
|
||||
CurNode->m_NextNode->m_ParentNode = CurNode;
|
||||
|
||||
@ -982,7 +982,7 @@ next [a] Null [a] <-- added NewNode
|
||||
if (Extract == false)
|
||||
{
|
||||
// CONSTRUCT A CHILD NODE
|
||||
assert(! CurNode->m_NextNode);
|
||||
debug_assert(! CurNode->m_NextNode);
|
||||
CurNode->m_NextNode = new CParserTaskTypeNode();
|
||||
CurNode->m_NextNode->m_ParentNode = CurNode;
|
||||
|
||||
|
@ -27,7 +27,7 @@ class Singleton
|
||||
public:
|
||||
Singleton()
|
||||
{
|
||||
assert2( !ms_singleton );
|
||||
debug_assert( !ms_singleton );
|
||||
|
||||
//use a cunning trick to get the singleton pointing to the start of
|
||||
//the whole, rather than the start of the Singleton part of the object
|
||||
@ -37,19 +37,19 @@ class Singleton
|
||||
|
||||
~Singleton()
|
||||
{
|
||||
assert2( ms_singleton );
|
||||
debug_assert( ms_singleton );
|
||||
ms_singleton=0;
|
||||
}
|
||||
|
||||
static T& GetSingleton()
|
||||
{
|
||||
assert2( ms_singleton );
|
||||
debug_assert( ms_singleton );
|
||||
return *ms_singleton;
|
||||
}
|
||||
|
||||
static T* GetSingletonPtr()
|
||||
{
|
||||
assert2( ms_singleton );
|
||||
debug_assert( ms_singleton );
|
||||
return ms_singleton;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "StringConvert.h"
|
||||
#include "lib/types.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "scripting/SpiderMonkey.h"
|
||||
|
||||
@ -50,7 +50,7 @@ void StringConvert::jsstring_to_wstring(JSString* str, std::wstring& result)
|
||||
|
||||
void StringConvert::jschars_to_wstring(const jschar* chars, size_t len, std::wstring& result)
|
||||
{
|
||||
assert(result.empty());
|
||||
debug_assert(result.empty());
|
||||
result.resize(len);
|
||||
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
@ -60,7 +60,7 @@ void StringConvert::jschars_to_wstring(const jschar* chars, size_t len, std::wst
|
||||
|
||||
void StringConvert::ucs2le_to_wstring(const char* start, const char* end, std::wstring& result)
|
||||
{
|
||||
assert(result.empty());
|
||||
debug_assert(result.empty());
|
||||
result.resize((end-start)/2);
|
||||
|
||||
size_t i = 0;
|
||||
|
@ -87,7 +87,7 @@ void XMLWriter_File::ElementEnd(const char* name, int type)
|
||||
m_Data += "\n" + Indent() + "</" + name += ">";
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
debug_assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ template <> void XMLWriter_File::ElementAttribute<CStr>(const char* name, const
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(m_LastElement && m_LastElement->m_Type == EL_ATTR);
|
||||
debug_assert(m_LastElement && m_LastElement->m_Type == EL_ATTR);
|
||||
m_Data += " ";
|
||||
m_Data += name;
|
||||
m_Data += "=\"" + value + "\"";
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "ps/utf16string.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
const int HeaderMagic = 0x30424D58; // = "XMB0" (little-endian)
|
||||
const char* HeaderMagicStr = "XMB0";
|
||||
@ -17,7 +17,7 @@ void XMBFile::Initialise(char* FileData)
|
||||
{
|
||||
m_Pointer = FileData;
|
||||
int Header = *(int*)m_Pointer; m_Pointer += 4;
|
||||
assert(Header == HeaderMagic && "Invalid XMB header!");
|
||||
debug_assert(Header == HeaderMagic && "Invalid XMB header!");
|
||||
|
||||
int i;
|
||||
|
||||
@ -178,7 +178,7 @@ int XMBElement::getLineNumber() const
|
||||
|
||||
XMBElement XMBElementList::item(const int id)
|
||||
{
|
||||
assert(id >= 0 && id < Count && "Element ID out of range");
|
||||
debug_assert(id >= 0 && id < Count && "Element ID out of range");
|
||||
char* Pos;
|
||||
|
||||
// If access is sequential, don't bother scanning
|
||||
@ -221,7 +221,7 @@ utf16string XMBAttributeList::getNamedItem(const int AttributeName) const
|
||||
|
||||
XMBAttribute XMBAttributeList::item(const int id)
|
||||
{
|
||||
assert(id >= 0 && id < Count && "Attribute ID out of range");
|
||||
debug_assert(id >= 0 && id < Count && "Attribute ID out of range");
|
||||
char* Pos;
|
||||
|
||||
// If access is sequential, don't bother scanning through
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
membuffer()
|
||||
{
|
||||
buffer = (char*)malloc(bufferinc);
|
||||
assert(buffer);
|
||||
debug_assert(buffer);
|
||||
allocated = bufferinc;
|
||||
length = 0;
|
||||
}
|
||||
@ -66,7 +66,7 @@ public:
|
||||
|
||||
void write(const void* data, int size, int offset)
|
||||
{
|
||||
assert(offset >= 0 && offset+size <= length);
|
||||
debug_assert(offset >= 0 && offset+size <= length);
|
||||
memcpy(&buffer[offset], data, size);
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ private:
|
||||
{
|
||||
allocated += bufferinc;
|
||||
buffer = (char*)realloc(buffer, allocated);
|
||||
assert(buffer);
|
||||
debug_assert(buffer);
|
||||
}
|
||||
};
|
||||
|
||||
@ -325,8 +325,8 @@ bool CXeromyces::ReadXMBFile(const char* filename)
|
||||
|
||||
const void* buffer = file->GetBuffer();
|
||||
|
||||
assert(file->GetBufferSize() >= 42 && "Invalid XMB file"); // 42 bytes is the smallest possible XMB. (Well, maybe not quite, but it's a nice number.)
|
||||
assert(*(int*)buffer == HeaderMagic && "Invalid XMB file header");
|
||||
debug_assert(file->GetBufferSize() >= 42 && "Invalid XMB file"); // 42 bytes is the smallest possible XMB. (Well, maybe not quite, but it's a nice number.)
|
||||
debug_assert(*(int*)buffer == HeaderMagic && "Invalid XMB file header");
|
||||
|
||||
// Store the Handle so it can be closed later
|
||||
XMBFileHandle = file;
|
||||
@ -433,7 +433,7 @@ void XeroHandler::CreateXMB()
|
||||
}
|
||||
|
||||
// All the XML contents must be surrounded by a single element
|
||||
assert(Root->childs.size() == 1);
|
||||
debug_assert(Root->childs.size() == 1);
|
||||
|
||||
OutputElement(Root->childs[0]);
|
||||
|
||||
|
@ -24,7 +24,7 @@ bool I18n::LoadLanguage(const char* name)
|
||||
if (name == NULL)
|
||||
{
|
||||
CLocale_interface* locale_ptr = I18n::NewLocale(NULL, NULL);
|
||||
assert(locale_ptr);
|
||||
debug_assert(locale_ptr);
|
||||
delete g_CurrentLocale;
|
||||
g_CurrentLocale = locale_ptr;
|
||||
g_CurrentLocaleName = "";
|
||||
|
@ -313,7 +313,7 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::E
|
||||
|
||||
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Subset( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc > 0 );
|
||||
debug_assert( argc > 0 );
|
||||
|
||||
std::vector<T>* Set = RetrieveSet( cx, obj );
|
||||
if( !Set )
|
||||
@ -355,7 +355,7 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::C
|
||||
|
||||
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Push( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc > 0 );
|
||||
debug_assert( argc > 0 );
|
||||
|
||||
std::vector<T>* Set = RetrieveSet( cx, obj );
|
||||
if( !Set )
|
||||
@ -392,7 +392,7 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::P
|
||||
|
||||
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Remove( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc > 0 );
|
||||
debug_assert( argc > 0 );
|
||||
|
||||
|
||||
std::vector<T>* Set = RetrieveSet( cx, obj );
|
||||
|
@ -84,7 +84,7 @@ JSBool JSI_Console::getConsole( JSContext* cx, JSObject* obj, jsval id, jsval* v
|
||||
|
||||
JSBool JSI_Console::writeConsole( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
|
||||
{
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
CStrW output;
|
||||
for( unsigned int i = 0; i < argc; i++ )
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* obj, uintN argc, jsval*
|
||||
// get arguments
|
||||
//
|
||||
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
CStr path;
|
||||
if( !ToPrimitive<CStr>( cx, argv[0], path ) )
|
||||
return( JS_FALSE );
|
||||
@ -109,7 +109,7 @@ JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* obj, uintN argc, jsval*
|
||||
// filename: VFS filename (may include path)
|
||||
JSBool JSI_VFS::GetFileMTime( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
CStr filename;
|
||||
if( !ToPrimitive<CStr>( cx, argv[0], filename ) )
|
||||
return( JS_FALSE );
|
||||
@ -129,7 +129,7 @@ JSBool JSI_VFS::GetFileMTime( JSContext* cx, JSObject* obj, uintN argc, jsval* a
|
||||
// filename: VFS filename (may include path)
|
||||
JSBool JSI_VFS::GetFileSize( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
CStr filename;
|
||||
if( !ToPrimitive<CStr>( cx, argv[0], filename ) )
|
||||
return( JS_FALSE );
|
||||
@ -149,7 +149,7 @@ JSBool JSI_VFS::GetFileSize( JSContext* cx, JSObject* obj, uintN argc, jsval* ar
|
||||
// filename: VFS filename (may include path)
|
||||
JSBool JSI_VFS::ReadFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
CStr filename;
|
||||
if( !ToPrimitive<CStr>( cx, argv[0], filename ) )
|
||||
return( JS_FALSE );
|
||||
@ -173,7 +173,7 @@ JSBool JSI_VFS::ReadFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv,
|
||||
// filename: VFS filename (may include path)
|
||||
JSBool JSI_VFS::ReadFileLines( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
CStr filename;
|
||||
if( !ToPrimitive<CStr>( cx, argv[0], filename ) )
|
||||
return( JS_FALSE );
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include "res/ogl_tex.h"
|
||||
#include "Renderer.h"
|
||||
@ -21,7 +21,7 @@ std::vector<CModel*> CModelRData::m_Models;
|
||||
CModelRData::CModelRData(CModel* model)
|
||||
: m_Model(model), m_Vertices(0), m_Normals(0), m_Indices(0), m_VB(0), m_Flags(0)
|
||||
{
|
||||
assert(model);
|
||||
debug_assert(model);
|
||||
// build all data now
|
||||
Build();
|
||||
}
|
||||
@ -64,10 +64,10 @@ void CModelRData::Build()
|
||||
void CModelRData::BuildIndices()
|
||||
{
|
||||
CModelDefPtr mdef=m_Model->GetModelDef();
|
||||
assert(mdef);
|
||||
debug_assert(mdef);
|
||||
|
||||
// must have a valid vertex buffer by this point so we know where indices are supposed to start
|
||||
assert(m_VB);
|
||||
debug_assert(m_VB);
|
||||
|
||||
// allocate indices if we haven't got any already
|
||||
if (!m_Indices) {
|
||||
@ -104,7 +104,7 @@ static void SkinPoint(const SModelVertex& vertex,const CMatrix3D* matrices,CVect
|
||||
const SVertexBlend& blend=vertex.m_Blend;
|
||||
|
||||
// must have at least one valid bone if we're using SkinPoint
|
||||
assert(blend.m_Bone[0]!=0xff);
|
||||
debug_assert(blend.m_Bone[0]!=0xff);
|
||||
|
||||
const CMatrix3D& m=matrices[blend.m_Bone[0]];
|
||||
m.Transform(vertex.m_Coords,result);
|
||||
@ -125,7 +125,7 @@ static void SkinNormal(const SModelVertex& vertex,const CMatrix3D* invmatrices,C
|
||||
const SVertexBlend& blend=vertex.m_Blend;
|
||||
|
||||
// must have at least one valid bone if we're using SkinNormal
|
||||
assert(blend.m_Bone[0]!=0xff);
|
||||
debug_assert(blend.m_Bone[0]!=0xff);
|
||||
|
||||
const CMatrix3D& m=invmatrices[blend.m_Bone[0]];
|
||||
m.RotateTransposed(vertex.m_Norm,result);
|
||||
@ -299,7 +299,7 @@ float CModelRData::BackToFrontIndexSort(CMatrix3D& objToCam)
|
||||
// SubmitBatches: submit batches for this model to the vertex buffer
|
||||
void CModelRData::SubmitBatches()
|
||||
{
|
||||
assert(m_VB);
|
||||
debug_assert(m_VB);
|
||||
m_VB->m_Owner->AppendBatch(m_VB,m_Model->GetTexture()->GetHandle(),m_Model->GetModelDef()->GetNumFaces()*3,m_Indices);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include "Pyrogenesis.h"
|
||||
@ -47,7 +47,7 @@ static SColor4ub ConvertColor(const RGBColor& src)
|
||||
// CPatchRData constructor
|
||||
CPatchRData::CPatchRData(CPatch* patch) : m_Patch(patch), m_Vertices(0), m_VBBase(0), m_VBBlends(0)
|
||||
{
|
||||
assert(patch);
|
||||
debug_assert(patch);
|
||||
Build();
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ void CPatchRData::BuildBlends()
|
||||
m_BlendSplats.resize(splatTextures.size());
|
||||
int splatCount=0;
|
||||
|
||||
assert(m_VBBlends->m_Index < 65536);
|
||||
debug_assert(m_VBBlends->m_Index < 65536);
|
||||
unsigned short base = (unsigned short)m_VBBlends->m_Index;
|
||||
std::set<Handle>::iterator iter=splatTextures.begin();
|
||||
for (;iter!=splatTextures.end();++iter) {
|
||||
@ -297,7 +297,7 @@ void CPatchRData::BuildBlends()
|
||||
void CPatchRData::BuildIndices()
|
||||
{
|
||||
// must have allocated some vertices before trying to build corresponding indices
|
||||
assert(m_VBBase);
|
||||
debug_assert(m_VBBase);
|
||||
|
||||
// number of vertices in each direction in each patch
|
||||
int vsize=PATCH_SIZE+1;
|
||||
@ -422,7 +422,7 @@ void CPatchRData::Update()
|
||||
|
||||
void CPatchRData::RenderBase()
|
||||
{
|
||||
assert(m_UpdateFlags==0);
|
||||
debug_assert(m_UpdateFlags==0);
|
||||
|
||||
u8* base=m_VBBase->m_Owner->Bind();
|
||||
|
||||
@ -445,7 +445,7 @@ void CPatchRData::RenderBase()
|
||||
|
||||
void CPatchRData::RenderStreams(u32 streamflags)
|
||||
{
|
||||
assert(m_UpdateFlags==0);
|
||||
debug_assert(m_UpdateFlags==0);
|
||||
|
||||
u8* base=m_VBBase->m_Owner->Bind();
|
||||
|
||||
@ -468,7 +468,7 @@ void CPatchRData::RenderStreams(u32 streamflags)
|
||||
|
||||
void CPatchRData::RenderBlends()
|
||||
{
|
||||
assert(m_UpdateFlags==0);
|
||||
debug_assert(m_UpdateFlags==0);
|
||||
|
||||
if (m_BlendVertices.size()==0) return;
|
||||
|
||||
@ -549,7 +549,7 @@ void CPatchRData::RenderOutline()
|
||||
// SubmitBaseBatches: submit base batches for this patch to the vertex buffer
|
||||
void CPatchRData::SubmitBaseBatches()
|
||||
{
|
||||
assert(m_VBBase);
|
||||
debug_assert(m_VBBase);
|
||||
|
||||
for (uint i=0;i<m_Splats.size();i++) {
|
||||
const SSplat& splat=m_Splats[i];
|
||||
|
@ -188,13 +188,13 @@ void CVertexBuffer::AppendBatch(VBChunk* UNUSEDPARAM(chunk),Handle texture,size_
|
||||
void CVertexBuffer::UpdateChunkVertices(VBChunk* chunk,void* data)
|
||||
{
|
||||
if (g_Renderer.m_Caps.m_VBO) {
|
||||
assert(m_Handle);
|
||||
debug_assert(m_Handle);
|
||||
glGetError(); // clear the error state
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB,m_Handle);
|
||||
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB,chunk->m_Index*m_VertexSize,chunk->m_Count*m_VertexSize,data);
|
||||
if (glGetError() != GL_NO_ERROR) throw PSERROR_Renderer_VBOFailed();
|
||||
} else {
|
||||
assert(m_SysMem);
|
||||
debug_assert(m_SysMem);
|
||||
memcpy(m_SysMem+chunk->m_Index*m_VertexSize,data,chunk->m_Count*m_VertexSize);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "precompiled.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include "ogl.h"
|
||||
#include "VertexBufferManager.h"
|
||||
#include "ps/CLogger.h"
|
||||
@ -51,12 +51,12 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize,size_t
|
||||
m_Buffers.push_front(buffer);
|
||||
result=buffer->Allocate(vertexSize,numVertices,dynamic);
|
||||
|
||||
// TODO, RC - assert not really suitable? probably need to handle "failed to create
|
||||
// TODO, RC - debug_assert not really suitable? probably need to handle "failed to create
|
||||
// VBO case" better
|
||||
if (!result)
|
||||
{
|
||||
LOG(ERROR, LOG_CATEGORY, "Failed to create VBOs");
|
||||
assert2(!"Failed to create VBOs");
|
||||
debug_assert(!"Failed to create VBOs");
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -66,7 +66,7 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize,size_t
|
||||
// Release: return given chunk to it's owner
|
||||
void CVertexBufferManager::Release(CVertexBuffer::VBChunk* chunk)
|
||||
{
|
||||
assert(chunk);
|
||||
debug_assert(chunk);
|
||||
chunk->m_Owner->Release(chunk);
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ bool IEventTarget::RemoveHandler( CStrW TypeString, DOMEventHandler handler )
|
||||
|
||||
bool IEventTarget::AddHandlerJS( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
assert( argc >= 2 );
|
||||
debug_assert( argc >= 2 );
|
||||
DOMEventHandler handler = new CScriptObject( argv[1] );
|
||||
if( !handler->Defined() )
|
||||
{
|
||||
@ -119,7 +119,7 @@ bool IEventTarget::AddHandlerJS( JSContext* cx, uintN argc, jsval* argv )
|
||||
|
||||
bool IEventTarget::RemoveHandlerJS( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
assert( argc >= 2 );
|
||||
debug_assert( argc >= 2 );
|
||||
DOMEventHandler handler = new CScriptObject( argv[1] );
|
||||
if( !handler->Defined() )
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
case TAG_STRING:
|
||||
return( 1 + (ToPrimitive<CStrW>(m_data)).GetSerializedLength() );
|
||||
default:
|
||||
assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." );
|
||||
debug_assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." );
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ public:
|
||||
buffer = ( ToPrimitive<CStrW>( m_data ) ).Serialize( buffer );
|
||||
break;
|
||||
default:
|
||||
assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." );
|
||||
debug_assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." );
|
||||
break;
|
||||
}
|
||||
return( buffer );
|
||||
@ -127,7 +127,7 @@ public:
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert( 0 && "An attempt was made to deserialize a jsval other than a number, boolean or string." );
|
||||
debug_assert( 0 && "An attempt was made to deserialize a jsval other than a number, boolean or string." );
|
||||
break;
|
||||
}
|
||||
return( buffer );
|
||||
|
@ -70,7 +70,7 @@ jsval SColour::ToString( JSContext* cx, uintN argc, jsval* argv )
|
||||
|
||||
JSBool SColour::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 3 );
|
||||
debug_assert( argc >= 3 );
|
||||
float alpha = 1.0;
|
||||
if( argc >= 4 ) alpha = ToPrimitive<float>( argv[3] );
|
||||
|
||||
|
@ -146,7 +146,7 @@ JSBool WriteLog(JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigne
|
||||
|
||||
JSBool getEntityByHandle( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
i32 handle;
|
||||
try
|
||||
{
|
||||
@ -173,7 +173,7 @@ JSBool getEntityByHandle( JSContext* context, JSObject* UNUSEDPARAM(globalObject
|
||||
|
||||
JSBool getEntityTemplate( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
CStrW templateName;
|
||||
try
|
||||
{
|
||||
@ -280,7 +280,7 @@ JSBool setCameraTarget( JSContext* context, JSObject* obj, unsigned int argc, js
|
||||
|
||||
JSBool setTimeout( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
|
||||
{
|
||||
assert( argc >= 2 );
|
||||
debug_assert( argc >= 2 );
|
||||
size_t delay;
|
||||
try
|
||||
{
|
||||
@ -314,7 +314,7 @@ JSBool setTimeout( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsi
|
||||
|
||||
JSBool setInterval( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
|
||||
{
|
||||
assert( argc >= 2 );
|
||||
debug_assert( argc >= 2 );
|
||||
size_t first, interval;
|
||||
try
|
||||
{
|
||||
@ -364,7 +364,7 @@ JSBool cancelInterval( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(gl
|
||||
|
||||
JSBool v3dist( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
assert( argc >= 2 );
|
||||
debug_assert( argc >= 2 );
|
||||
CVector3D* a = ToNative<CVector3D>( argv[0] );
|
||||
CVector3D* b = ToNative<CVector3D>( argv[1] );
|
||||
float dist = ( *a - *b ).GetLength();
|
||||
@ -400,7 +400,7 @@ JSBool setCursor(JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalOb
|
||||
{
|
||||
if (argc != 1)
|
||||
{
|
||||
assert(! "Invalid parameter count to setCursor");
|
||||
debug_assert(! "Invalid parameter count to setCursor");
|
||||
return JS_FALSE;
|
||||
}
|
||||
g_CursorName = g_ScriptingHost.ValueToString(argv[0]);
|
||||
@ -577,8 +577,8 @@ JSBool _lodbias(JSContext* context, JSObject* globalObject, unsigned int argc, j
|
||||
|
||||
JSBool issueCommand(JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
assert(argc >= 2);
|
||||
assert(JSVAL_IS_OBJECT(argv[0]));
|
||||
debug_assert(argc >= 2);
|
||||
debug_assert(JSVAL_IS_OBJECT(argv[0]));
|
||||
|
||||
CEntityList entities;
|
||||
|
||||
|
@ -413,7 +413,7 @@ public:
|
||||
}
|
||||
void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty )
|
||||
{
|
||||
assert( 0 && "ImmediateCopy called on a CJSValComplexProperty (something's gone wrong with the inheritance on this object)" );
|
||||
debug_assert( 0 && "ImmediateCopy called on a CJSValComplexProperty (something's gone wrong with the inheritance on this object)" );
|
||||
}
|
||||
};
|
||||
|
||||
@ -433,7 +433,7 @@ public:
|
||||
m_Getter = Getter;
|
||||
m_Setter = Setter;
|
||||
// Must at least be able to read
|
||||
assert( m_Getter );
|
||||
debug_assert( m_Getter );
|
||||
}
|
||||
jsval Get( JSContext* cx, IJSComplex* owner )
|
||||
{
|
||||
@ -446,7 +446,7 @@ public:
|
||||
}
|
||||
void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty )
|
||||
{
|
||||
assert( 0 && "ImmediateCopy called on a property wrapping getter/setter functions (something's gone wrong with the inheritance for this object)" );
|
||||
debug_assert( 0 && "ImmediateCopy called on a property wrapping getter/setter functions (something's gone wrong with the inheritance for this object)" );
|
||||
}
|
||||
};
|
||||
|
||||
@ -633,7 +633,7 @@ public:
|
||||
if( !Native )
|
||||
return( JS_TRUE );
|
||||
|
||||
assert( argc >= 1 );
|
||||
debug_assert( argc >= 1 );
|
||||
|
||||
CScriptObject watch( argv[0] );
|
||||
std::vector<CScriptObject>::iterator it;
|
||||
@ -777,7 +777,7 @@ public:
|
||||
if( extProp->m_JSAccessor )
|
||||
{
|
||||
CJSComplexPropertyAccessor< CJSComplex<T, ReadOnly> >* accessor = (CJSComplexPropertyAccessor< CJSComplex<T, ReadOnly> >*)JS_GetPrivate( g_ScriptingHost.GetContext(), extProp->m_JSAccessor );
|
||||
assert( accessor );
|
||||
debug_assert( accessor );
|
||||
delete( accessor );
|
||||
JS_SetPrivate( g_ScriptingHost.GetContext(), extProp->m_JSAccessor, NULL );
|
||||
JS_RemoveRoot( g_ScriptingHost.GetContext(), &( extProp->m_JSAccessor ) );
|
||||
@ -791,7 +791,7 @@ public:
|
||||
for( it_a = m_Reflectors.begin(); it_a != m_Reflectors.end(); it_a++ )
|
||||
{
|
||||
CJSComplexPropertyAccessor< CJSComplex<T, ReadOnly> >* accessor = (CJSComplexPropertyAccessor< CJSComplex<T, ReadOnly> >*)JS_GetPrivate( g_ScriptingHost.GetContext(), it_a->second->m_JSAccessor );
|
||||
assert( accessor );
|
||||
debug_assert( accessor );
|
||||
delete( accessor );
|
||||
JS_SetPrivate( g_ScriptingHost.GetContext(), it_a->second->m_JSAccessor, NULL );
|
||||
JS_RemoveRoot( g_ScriptingHost.GetContext(), &( it_a->second->m_JSAccessor ) );
|
||||
@ -839,7 +839,7 @@ public:
|
||||
// If it can be inherited, inherit it.
|
||||
if( cp && cp->m_AllowsInheritance )
|
||||
{
|
||||
assert( cp->m_Intrinsic );
|
||||
debug_assert( cp->m_Intrinsic );
|
||||
it->second->ImmediateCopy( this, m_Parent, cp );
|
||||
}
|
||||
}
|
||||
@ -853,7 +853,7 @@ public:
|
||||
|
||||
if( cp && cp->m_AllowsInheritance )
|
||||
{
|
||||
assert( cp->m_Intrinsic );
|
||||
debug_assert( cp->m_Intrinsic );
|
||||
it->second->ImmediateCopy( this, m_Parent, cp );
|
||||
}
|
||||
}
|
||||
@ -897,7 +897,7 @@ public:
|
||||
}
|
||||
void AddProperty( CStrW PropertyName, jsval Value )
|
||||
{
|
||||
assert( !HasProperty( PropertyName ) );
|
||||
debug_assert( !HasProperty( PropertyName ) );
|
||||
CJSDynamicComplexProperty* newProp = new CJSValComplexProperty( Value, false );
|
||||
m_Properties[PropertyName] = newProp;
|
||||
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
m_Getter = Getter;
|
||||
m_Setter = Setter;
|
||||
// Must at least be able to read
|
||||
assert( m_Getter );
|
||||
debug_assert( m_Getter );
|
||||
}
|
||||
jsval Get( JSContext* cx, IJSObject* obj )
|
||||
{
|
||||
@ -279,7 +279,7 @@ public:
|
||||
|
||||
void AddProperty( CStrW PropertyName, jsval Value )
|
||||
{
|
||||
assert( !HasProperty( PropertyName ) );
|
||||
debug_assert( !HasProperty( PropertyName ) );
|
||||
CJSValProperty* newProp = new CJSValProperty( Value );
|
||||
m_ScriptProperties[PropertyName] = newProp;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ void ScriptingHost::LoadScriptFromDisk(const std::string & fileName)
|
||||
JSBool ok = JS_EvaluateScript(m_Context, m_GlobalObject, (const char*)script, (unsigned int)script_len, fn, 0, &rval);
|
||||
|
||||
int err = mem_free(script);
|
||||
assert(err == 0);
|
||||
debug_assert(err == 0);
|
||||
|
||||
if (ok == JS_FALSE)
|
||||
throw PSERROR_Scripting_LoadFile_EvalErrors();
|
||||
@ -130,7 +130,7 @@ jsval ScriptingHost::ExecuteScript(const CStrW& script, const CStrW& calledFrom,
|
||||
/* Unicode->ASCII conversion (mostly) for calledFrom */
|
||||
|
||||
size_t len = wcstombs( NULL, calledFrom, 0 );
|
||||
assert( len != (size_t)-1 );
|
||||
debug_assert( len != (size_t)-1 );
|
||||
char* asciiName = new char[len + 1];
|
||||
wcstombs( asciiName, calledFrom, len + 1 );
|
||||
|
||||
|
@ -257,7 +257,7 @@ bool CBaseEntity::loadXML( CStr filename )
|
||||
{
|
||||
jsval fnval;
|
||||
JSBool ret = JS_GetUCProperty( g_ScriptingHost.GetContext(), g_ScriptingHost.GetGlobalObject(), ExternalFunction.c_str(), ExternalFunction.size(), &fnval );
|
||||
assert( ret );
|
||||
debug_assert( ret );
|
||||
JSFunction* fn = JS_ValueToFunction( g_ScriptingHost.GetContext(), fnval );
|
||||
if( !fn )
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user