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

C++ M_Free函数代码示例

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

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



在下文中一共展示了M_Free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
	}
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:34,代码来源:farchive.cpp


示例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;
}
开发者ID:WChrisK,项目名称:OdaStats,代码行数:71,代码来源:w_wad.cpp


示例3: M_Free

Id1Map::~Id1Map()
{
    if(vertexes)
    {
        M_Free(vertexes);
        vertexes = 0;
    }

    DENG2_FOR_EACH(Polyobjs, i, polyobjs)
    {
        M_Free(i->lineIndices);
    }
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:12,代码来源:id1map.cpp


示例4: M_Free

PClass::~PClass()
{
	if (Defaults != nullptr)
	{
		M_Free(Defaults);
		Defaults = nullptr;
	}
	if (Meta != nullptr)
	{
		M_Free(Meta);
		Meta = nullptr;
	}
}
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:13,代码来源:dobjtype.cpp


示例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;
	}
}
开发者ID:AkumaKing,项目名称:Xeu,代码行数:49,代码来源:anim_switches.cpp


示例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();
}
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:48,代码来源:texturemanager.cpp


示例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);
}
开发者ID:Jayman2000,项目名称:zdoom-pull,代码行数:26,代码来源:p_states.cpp


示例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;
}
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:27,代码来源:str.c


示例9: Rectf_Delete

void Rectf_Delete(Rectf *r)
{
    DENG_ASSERT(r);
    Point2f_Delete(r->origin);
    Size2f_Delete(r->size);
    M_Free(r);
}
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:7,代码来源:rect.c


示例10: Rect_Delete

void Rect_Delete(Rect *r)
{
    if(!r) return;
    Point2_Delete(r->origin);
    Size2_Delete(r->size);
    M_Free(r);
}
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:7,代码来源:rect.c


示例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);
	}
}
开发者ID:Xeomuz,项目名称:Doom-Port-Source-Code,代码行数:27,代码来源:stringtable.cpp


示例12: NewDoubleProd

static FDoubleProd *StringToDouble (FProduction *prod)
{
	FDoubleProd *newprod;
	
	newprod = NewDoubleProd (atof (static_cast<FStringProd *>(prod)->Value));
	M_Free (prod);
	return newprod;
}
开发者ID:Accusedbold,项目名称:zdoom,代码行数:8,代码来源:c_expr.cpp


示例13: deleteString

static void deleteString(Str *str)
{
    DENG_ASSERT(str);
    if(!str) return;

    Str_Free(str);
    M_Free(str);
}
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:8,代码来源:str.c


示例14: Close

FArchive::~FArchive ()
{
	Close ();
	if (m_TypeMap)
		delete[] m_TypeMap;
	if (m_ObjectMap)
		M_Free(m_ObjectMap);
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:8,代码来源:farchive.cpp


示例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;
}
开发者ID:dwing4g,项目名称:gzdoom,代码行数:9,代码来源:memarena.cpp


示例16: LOG_AS

size_t Zip::readLump(int lumpIdx, uint8_t* buffer, size_t startOffset,
                     size_t length, bool tryCache)
{
    LOG_AS("Zip::readLump");
    ZipFile const& file = reinterpret_cast<ZipFile&>(lump(lumpIdx));

    LOG_TRACE("\"%s:%s\" (%u bytes%s) [%u +%u]")
            << de::NativePath(composePath()).pretty()
            << de::NativePath(file.composePath()).pretty()
            << (unsigned long) file.size()
            << (file.isCompressed()? ", compressed" : "")
            << startOffset
            << length;

    // Try to avoid a file system read by checking for a cached copy.
    if(tryCache)
    {
        uint8_t const* data = d->lumpCache? d->lumpCache->data(lumpIdx) : 0;
        LOG_TRACE("Cache %s on #%i") << (data? "hit" : "miss") << lumpIdx;
        if(data)
        {
            size_t readBytes = MIN_OF(file.size(), length);
            memcpy(buffer, data + startOffset, readBytes);
            return readBytes;
        }
    }

    size_t readBytes;
    if(!startOffset && length == file.size())
    {
        // Read it straight to the caller's data buffer.
        readBytes = d->bufferLump(file, buffer);
    }
    else
    {
        // Allocate a temporary buffer and read the whole lump into it(!).
        uint8_t* lumpData = (uint8_t*) M_Malloc(file.size());
        if(!lumpData) throw Error("Zip::readLumpSection", QString("Failed on allocation of %1 bytes for work buffer").arg(file.size()));

        if(d->bufferLump(file, lumpData))
        {
            readBytes = MIN_OF(file.size(), length);
            memcpy(buffer, lumpData + startOffset, readBytes);
        }
        else
        {
            readBytes = 0;
        }
        M_Free(lumpData);
    }

    /// @todo Do not check the read length here.
    if(readBytes < MIN_OF(file.size(), length))
        throw Error("Zip::readLumpSection", QString("Only read %1 of %2 bytes of lump #%3").arg(readBytes).arg(length).arg(lumpIdx));

    return readBytes;
}
开发者ID:roman313,项目名称:Doomsday-Engine,代码行数:57,代码来源:zip.cpp


示例17: N_ReleaseMessage

/**
 * Frees the message.
 */
void N_ReleaseMessage(netmessage_t *msg)
{
    if(msg->handle)
    {
        delete [] reinterpret_cast<byte *>(msg->handle);
        msg->handle = 0;
    }
    M_Free(msg);
}
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:12,代码来源:net_buf.cpp


示例18: M_Free

FName::NameManager::~NameManager()
{
	NameBlock *block, *next;

	for (block = Blocks; block != NULL; block = next)
	{
		next = block->NextBlock;
		M_Free (block);
	}
	Blocks = NULL;

	if (NameArray != NULL)
	{
		M_Free (NameArray);
		NameArray = NULL;
	}
	NumNames = MaxNames = 0;
	memset (Buckets, -1, sizeof(Buckets));
}
开发者ID:Edward850,项目名称:zdoom,代码行数:19,代码来源:name.cpp


示例19: mysnprintf

static FStringProd *DoubleToString (FProduction *prod)
{
	char buf[128];
	FStringProd *newprod;

	mysnprintf (buf, countof(buf), "%g", static_cast<FDoubleProd *>(prod)->Value);
	newprod = NewStringProd (buf);
	M_Free (prod);
	return newprod;
}
开发者ID:Accusedbold,项目名称:zdoom,代码行数:10,代码来源:c_expr.cpp


示例20: M_Free

AnimArray::~AnimArray()
{
	for (unsigned i = 0; i < Size(); i++)
	{
		if ((*this)[i] != NULL)
		{
			M_Free ((*this)[i]);
			(*this)[i] = NULL;
		}
	}
}
开发者ID:Xeomuz,项目名称:Doom-Port-Source-Code,代码行数:11,代码来源:r_anim.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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