本文整理汇总了C++中M_Free函数的典型用法代码示例。如果您正苦于以下问题:C++ M_Free函数的具体用法?C++ M_Free怎么用?C++ M_Free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了M_Free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BELONG
void FLZOFile::Explode ()
{
unsigned int expandsize, cprlen;
unsigned char *expand;
if (m_Buffer)
{
unsigned int *ints = (unsigned int *)(m_Buffer);
cprlen = BELONG(ints[0]);
expandsize = BELONG(ints[1]);
expand = (unsigned char *)Malloc (expandsize);
if (cprlen)
{
unsigned int r;
lzo_uint newlen = expandsize;
r = lzo1x_decompress_safe (m_Buffer + 8, cprlen, expand, &newlen, NULL);
if (r != LZO_E_OK || newlen != expandsize)
{
M_Free(expand);
I_Error ("Could not decompress LZO file");
}
}
else
{
memcpy (expand, m_Buffer + 8, expandsize);
}
if (FreeOnExplode ())
M_Free(m_Buffer);
m_Buffer = expand;
m_BufferSize = expandsize;
}
}
示例2: W_InitMultipleFiles
//
// W_InitMultipleFiles
// Pass a null terminated list of files to use.
// All files are optional, but at least one file
// must be found.
// Files with a .wad extension are idlink files
// with multiple lumps.
// Other files are single lumps with the base filename
// for the lump name.
// Lump names can appear multiple times.
// The name searcher looks backwards, so a later file
// does override all earlier ones.
//
std::vector<std::string> W_InitMultipleFiles (std::vector<std::string> &filenames)
{
size_t size, i;
// open all the files, load headers, and count lumps
// will be realloced as lumps are added
numlumps = 0;
M_Free(lumpinfo);
std::vector<std::string> hashes(filenames);
// open each file once, load headers, and count lumps
int j = 0;
std::vector<std::string> loaded;
for(i = 0; i < filenames.size(); i++)
{
if(std::find(loaded.begin(), loaded.end(), filenames[i].c_str()) == loaded.end())
{
hashes[j++] = W_AddFile(filenames[i].c_str());
loaded.push_back(filenames[i].c_str());
}
}
filenames = loaded;
hashes.resize(j);
if (!numlumps)
I_Error ("W_InitFiles: no files found");
// [RH] Set namespace markers to global for everything
for (i = 0; i < numlumps; i++)
lumpinfo[i].namespc = ns_global;
// [RH] Merge sprite and flat groups.
// (We don't need to bother with patches, since
// Doom doesn't use markers to identify them.)
W_MergeLumps ("S_START", "S_END", ns_sprites); // denis - fixme - security
W_MergeLumps ("F_START", "F_END", ns_flats);
W_MergeLumps ("C_START", "C_END", ns_colormaps);
// set up caching
M_Free(lumpcache);
size = numlumps * sizeof(*lumpcache);
lumpcache = (void **)Malloc (size);
if (!lumpcache)
I_Error ("Couldn't allocate lumpcache");
memset (lumpcache,0, size);
// killough 1/31/98: initialize lump hash table
W_HashLumps();
stdisk_lumpnum = W_GetNumForName("STDISK");
return hashes;
}
示例3: M_Free
Id1Map::~Id1Map()
{
if(vertexes)
{
M_Free(vertexes);
vertexes = 0;
}
DENG2_FOR_EACH(Polyobjs, i, polyobjs)
{
M_Free(i->lineIndices);
}
示例4: M_Free
PClass::~PClass()
{
if (Defaults != nullptr)
{
M_Free(Defaults);
Defaults = nullptr;
}
if (Meta != nullptr)
{
M_Free(Meta);
Meta = nullptr;
}
}
示例5: M_Free
void FTextureManager::AddSwitchPair (FSwitchDef *def1, FSwitchDef *def2)
{
unsigned int i;
FSwitchDef *sw1 = NULL;
FSwitchDef *sw2 = NULL;
unsigned int index1 = 0xffffffff, index2 = 0xffffffff;
for (i = mSwitchDefs.Size (); i-- > 0; )
{
if (mSwitchDefs[i]->PreTexture == def1->PreTexture)
{
index1 = i;
sw1 = mSwitchDefs[index1];
if (index2 != 0xffffffff) break;
}
if (mSwitchDefs[i]->PreTexture == def2->PreTexture)
{
index2 = i;
sw2 = mSwitchDefs[index2];
if (index1 != 0xffffffff) break;
}
}
def1->PairDef = def2;
def2->PairDef = def1;
if (sw1 != NULL && sw2 != NULL && sw1->PairDef == sw2 && sw2->PairDef == sw1)
{
//We are replacing an existing pair so we can safely delete the old definitions
M_Free(sw1);
M_Free(sw2);
mSwitchDefs[index1] = def1;
mSwitchDefs[index2] = def2;
}
else
{
// This new switch will not or only partially replace an existing pair.
// We should not break up an old pair if the new one only redefined one
// of the two textures. These paired definitions will only be used
// as the return animation so their names don't matter. Better clear them to be safe.
if (sw1 != NULL) sw1->PreTexture.SetInvalid();
if (sw2 != NULL) sw2->PreTexture.SetInvalid();
sw1 = NULL;
sw2 = NULL;
unsigned int pos = mSwitchDefs.Reserve(2);
mSwitchDefs[pos] = def1;
mSwitchDefs[pos+1] = def2;
}
}
示例6: memset
void FTextureManager::DeleteAll()
{
for (unsigned int i = 0; i < Textures.Size(); ++i)
{
delete Textures[i].Texture;
}
Textures.Clear();
Translation.Clear();
FirstTextureForFile.Clear();
memset (HashFirst, -1, sizeof(HashFirst));
DefaultTexture.SetInvalid();
for (unsigned i = 0; i < mAnimations.Size(); i++)
{
if (mAnimations[i] != NULL)
{
M_Free (mAnimations[i]);
mAnimations[i] = NULL;
}
}
mAnimations.Clear();
for (unsigned i = 0; i < mSwitchDefs.Size(); i++)
{
if (mSwitchDefs[i] != NULL)
{
M_Free (mSwitchDefs[i]);
mSwitchDefs[i] = NULL;
}
}
mSwitchDefs.Clear();
for (unsigned i = 0; i < mAnimatedDoors.Size(); i++)
{
if (mAnimatedDoors[i].TextureFrames != NULL)
{
delete mAnimatedDoors[i].TextureFrames;
mAnimatedDoors[i].TextureFrames = NULL;
}
}
mAnimatedDoors.Clear();
for (unsigned int i = 0; i < BuildTileFiles.Size(); ++i)
{
delete[] BuildTileFiles[i];
}
BuildTileFiles.Clear();
}
示例7: FindState
void FStateDefinitions::InstallStates(PClassActor *info, AActor *defaults)
{
// First ensure we have a valid spawn state.
FState *state = FindState("Spawn");
if (state == NULL)
{
// A NULL spawn state will crash the engine so set it to something valid.
SetStateLabel("Spawn", GetDefault<AActor>()->SpawnState);
}
if (info->StateList != NULL)
{
info->StateList->Destroy();
M_Free(info->StateList);
}
info->StateList = CreateStateLabelList(StateLabels);
// Cache these states as member veriables.
defaults->SpawnState = info->FindState(NAME_Spawn);
defaults->SeeState = info->FindState(NAME_See);
// Melee and Missile states are manipulated by the scripted marines so they
// have to be stored locally
defaults->MeleeState = info->FindState(NAME_Melee);
defaults->MissileState = info->FindState(NAME_Missile);
}
示例8: DENG_ASSERT
ddstring_t *Str_PartAppend(ddstring_t *str, char const *append, int start, int count)
{
int partLen;
char *copied;
DENG_ASSERT(str);
DENG_ASSERT(append);
if(!str || !append) return str;
if(start < 0 || count <= 0) return str;
copied = M_Malloc(count + 1);
copied[0] = 0; // empty string
strncat(copied, append + start, count);
partLen = strlen(copied);
allocateString(str, str->length + partLen + 1, true);
memcpy(str->str + str->length, copied, partLen);
str->length += partLen;
// Terminate the appended part.
str->str[str->length] = 0;
M_Free(copied);
return str;
}
示例9: Rectf_Delete
void Rectf_Delete(Rectf *r)
{
DENG_ASSERT(r);
Point2f_Delete(r->origin);
Size2f_Delete(r->size);
M_Free(r);
}
示例10: Rect_Delete
void Rect_Delete(Rect *r)
{
if(!r) return;
Point2_Delete(r->origin);
Size2_Delete(r->size);
M_Free(r);
}
示例11: FindString
void FStringTable::SetString (const char *name, const char *newString)
{
StringEntry **pentry, *oentry;
FindString (name, pentry, oentry);
size_t newlen = strlen (newString);
size_t namelen = strlen (name);
// Create a new string entry
StringEntry *entry = (StringEntry *)M_Malloc (sizeof(*entry) + newlen + namelen);
strcpy (entry->String, newString);
strcpy (entry->Name = entry->String + newlen + 1, name);
entry->PassNum = 0;
// If this is a new string, insert it. Otherwise, replace the old one.
if (oentry == NULL)
{
entry->Next = *pentry;
*pentry = entry;
}
else
{
*pentry = entry;
entry->Next = oentry->Next;
M_Free (oentry);
}
}
示例12: NewDoubleProd
static FDoubleProd *StringToDouble (FProduction *prod)
{
FDoubleProd *newprod;
newprod = NewDoubleProd (atof (static_cast<FStringProd *>(prod)->Value));
M_Free (prod);
return newprod;
}
示例13: deleteString
static void deleteString(Str *str)
{
DENG_ASSERT(str);
if(!str) return;
Str_Free(str);
M_Free(str);
}
示例14: Close
FArchive::~FArchive ()
{
Close ();
if (m_TypeMap)
delete[] m_TypeMap;
if (m_ObjectMap)
M_Free(m_ObjectMap);
}
示例15: M_Free
void FMemArena::FreeBlockChain(Block *&top)
{
for (Block *next, *block = top; block != NULL; block = next)
{
next = block->NextBlock;
M_Free(block);
}
top = NULL;
}