当前位置: 首页>>代码示例>>C++>>正文


C++ CFREE函数代码示例

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


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

示例1: ConfigSaveJSON

void ConfigSaveJSON(const Config *config, const char *filename)
{
	FILE *f = fopen(filename, "w");
	char *text = NULL;
	json_t *root;

	if (f == NULL)
	{
		printf("Error saving config '%s'\n", filename);
		return;
	}

	setlocale(LC_ALL, "");

	root = json_new_object();
	json_insert_pair_into_object(root, "Version", json_new_number(VERSION));
	ConfigSaveVisit(config, root);

	json_tree_to_string(root, &text);
	char *formatText = json_format_string(text);
	fputs(formatText, f);

	// clean up
	CFREE(formatText);
	CFREE(text);
	json_free_value(&root);

	fclose(f);
}
开发者ID:NSYXin,项目名称:cdogs-sdl,代码行数:29,代码来源:config_json.c

示例2: MissionTerminate

void MissionTerminate(Mission *m)
{
	CFREE(m->Title);
	CFREE(m->Description);
	for (int i = 0; i < (int)m->Objectives.size; i++)
	{
		MissionObjective *mo = CArrayGet(&m->Objectives, i);
		CFREE(mo->Description);
	}
	CArrayTerminate(&m->Objectives);
	CArrayTerminate(&m->Enemies);
	CArrayTerminate(&m->SpecialChars);
	CArrayTerminate(&m->Items);
	CArrayTerminate(&m->ItemDensities);
	CArrayTerminate(&m->Weapons);
	switch (m->Type)
	{
	case MAPTYPE_CLASSIC:
		break;
	case MAPTYPE_STATIC:
		CArrayTerminate(&m->u.Static.Tiles);
		CArrayTerminate(&m->u.Static.Items);
		CArrayTerminate(&m->u.Static.Wrecks);
		CArrayTerminate(&m->u.Static.Characters);
		CArrayTerminate(&m->u.Static.Objectives);
		CArrayTerminate(&m->u.Static.Keys);
		break;
	}
}
开发者ID:kodephys,项目名称:cdogs-sdl,代码行数:29,代码来源:mission.c

示例3: CampaignIntroDraw

static void CampaignIntroDraw(void *data)
{
	// This will only draw once
	const CampaignSetting *c = data;

	GraphicsBlitBkg(&gGraphicsDevice);
	const int w = gGraphicsDevice.cachedConfig.Res.x;
	const int h = gGraphicsDevice.cachedConfig.Res.y;
	const int y = h / 4;

	// Display title + author
	char *buf;
	CMALLOC(buf, strlen(c->Title) + strlen(c->Author) + 16);
	sprintf(buf, "%s by %s", c->Title, c->Author);
	FontOpts opts = FontOptsNew();
	opts.HAlign = ALIGN_CENTER;
	opts.Area = gGraphicsDevice.cachedConfig.Res;
	opts.Pad.y = y - 25;
	FontStrOpt(buf, Vec2iZero(), opts);
	CFREE(buf);

	// Display campaign description
	// allow some slack for newlines
	if (strlen(c->Description) > 0)
	{
		CMALLOC(buf, strlen(c->Description) * 2);
		// Pad about 1/6th of the screen width total (1/12th left and right)
		FontSplitLines(c->Description, buf, w * 5 / 6);
		FontStr(buf, Vec2iNew(w / 12, y));
		CFREE(buf);
	}
}
开发者ID:Wuzzy2,项目名称:cdogs-sdl,代码行数:32,代码来源:briefing_screens.c

示例4: UIObjectDestroy

void UIObjectDestroy(UIObject *o)
{
	size_t i;
	UIObject **objs = o->Children.data;
	CFREE(o->Tooltip);
	for (i = 0; i < o->Children.size; i++, objs++)
	{
		UIObjectDestroy(*objs);
	}
	CArrayTerminate(&o->Children);
	if (o->IsDynamicData)
	{
		CFREE(o->Data);
	}
	switch (o->Type)
	{
	case UITYPE_TEXTBOX:
		CFREE(o->u.Textbox.Hint);
		break;
	case UITYPE_TAB:
		CArrayTerminate(&o->u.Tab.Labels);
		break;
	default:
		// do nothing
		break;
	}
	CFREE(o);
}
开发者ID:depoorterp,项目名称:cdogs-sdl,代码行数:28,代码来源:ui_object.c

示例5: ConvertCampaignSetting

void ConvertCampaignSetting(CampaignSetting *dest, CampaignSettingOld *src)
{
	int i;
	CFREE(dest->Title);
	CSTRDUP(dest->Title, src->title);
	CFREE(dest->Author);
	CSTRDUP(dest->Author, src->author);
	CFREE(dest->Description);
	CSTRDUP(dest->Description, src->description);
	for (i = 0; i < src->missionCount; i++)
	{
		Mission m;
		MissionInit(&m);
		ConvertMission(&m, &src->missions[i]);
		CArrayPushBack(&dest->Missions, &m);
	}
	CharacterStoreTerminate(&dest->characters);
	CharacterStoreInit(&dest->characters);
	for (i = 0; i < src->characterCount; i++)
	{
		Character *ch = CharacterStoreAddOther(&dest->characters);
		ConvertCharacter(ch, &src->characters[i]);
		CharacterSetLooks(ch, &ch->looks);
	}
}
开发者ID:kodephys,项目名称:cdogs-sdl,代码行数:25,代码来源:files.c

示例6: UIObjectDestroy

void UIObjectDestroy(UIObject *o)
{
	CFREE(o->Tooltip);
	CA_FOREACH(UIObject *, obj, o->Children)
		UIObjectDestroy(*obj);
	CA_FOREACH_END()
	CArrayTerminate(&o->Children);
	if (o->IsDynamicData)
	{
		CFREE(o->Data);
	}
	switch (o->Type)
	{
	case UITYPE_TEXTBOX:
		CFREE(o->u.Textbox.Hint);
		break;
	case UITYPE_TAB:
		CArrayTerminate(&o->u.Tab.Labels);
		break;
	default:
		// do nothing
		break;
	}
	CFREE(o);
}
开发者ID:FlyingTarrasque,项目名称:cdogs-sdl,代码行数:25,代码来源:ui_object.c

示例7: ConfigSaveJSON

void ConfigSaveJSON(Config *config, const char *filename)
{
	FILE *f = fopen(filename, "w");
	char *text = NULL;
	json_t *root;

	if (f == NULL)
	{
		printf("Error saving config '%s'\n", filename);
		return;
	}

	setlocale(LC_ALL, "");

	root = json_new_object();
	json_insert_pair_into_object(root, "Version", json_new_number(VERSION));
	AddGameConfigNode(&config->Game, root);
	AddGraphicsConfigNode(&config->Graphics, root);
	AddInputConfigNode(&config->Input, root);
	AddInterfaceConfigNode(&config->Interface, root);
	AddSoundConfigNode(&config->Sound, root);
	AddQuickPlayConfigNode(&config->QuickPlay, root);

	json_tree_to_string(root, &text);
	char *formatText = json_format_string(text);
	fputs(formatText, f);

	// clean up
	CFREE(formatText);
	CFREE(text);
	json_free_value(&root);

	fclose(f);
}
开发者ID:kodephys,项目名称:cdogs-sdl,代码行数:34,代码来源:config_json.c

示例8: ScreenMissionBriefing

bool ScreenMissionBriefing(const struct MissionOptions *m)
{
	const int w = gGraphicsDevice.cachedConfig.Res.x;
	const int h = gGraphicsDevice.cachedConfig.Res.y;
	const int y = h / 4;
	MissionBriefingData mData;
	memset(&mData, 0, sizeof mData);
	mData.IsOK = true;

	// Title
	CMALLOC(mData.Title, strlen(m->missionData->Title) + 32);
	sprintf(mData.Title, "Mission %d: %s",
		m->index + 1, m->missionData->Title);
	mData.TitleOpts = FontOptsNew();
	mData.TitleOpts.HAlign = ALIGN_CENTER;
	mData.TitleOpts.Area = gGraphicsDevice.cachedConfig.Res;
	mData.TitleOpts.Pad.y = y - 25;

	// Password
	if (m->index > 0)
	{
		sprintf(
			mData.Password, "Password: %s", gAutosave.LastMission.Password);
		mData.PasswordOpts = FontOptsNew();
		mData.PasswordOpts.HAlign = ALIGN_CENTER;
		mData.PasswordOpts.Area = gGraphicsDevice.cachedConfig.Res;
		mData.PasswordOpts.Pad.y = y - 15;
	}

	// Split the description, and prepare it for typewriter effect
	mData.TypewriterCount = 0;
	// allow some slack for newlines
	CMALLOC(mData.Description, strlen(m->missionData->Description) * 2 + 1);
	CCALLOC(mData.TypewriterBuf, strlen(m->missionData->Description) * 2 + 1);
	// Pad about 1/6th of the screen width total (1/12th left and right)
	FontSplitLines(m->missionData->Description, mData.Description, w * 5 / 6);
	mData.DescriptionPos = Vec2iNew(w / 12, y);

	// Objectives
	mData.ObjectiveDescPos =
		Vec2iNew(w / 6, y + FontStrH(mData.Description) + h / 10);
	mData.ObjectiveInfoPos =
		Vec2iNew(w - (w / 6), mData.ObjectiveDescPos.y + FontH());
	mData.ObjectiveHeight = h / 12;
	mData.MissionOptions = m;

	GameLoopData gData = GameLoopDataNew(
		&mData, MissionBriefingUpdate,
		&mData, MissionBriefingDraw);
	GameLoop(&gData);
	if (mData.IsOK)
	{
		SoundPlay(&gSoundDevice, StrSound("mg"));
	}

	CFREE(mData.Title);
	CFREE(mData.Description);
	CFREE(mData.TypewriterBuf);
	return mData.IsOK;
}
开发者ID:Wuzzy2,项目名称:cdogs-sdl,代码行数:60,代码来源:briefing_screens.c

示例9: TrySaveJSONFile

bool TrySaveJSONFile(json_t *node, const char *filename)
{
	bool res = true;
	char *text;
	json_tree_to_string(node, &text);
	char *ftext = json_format_string(text);
	FILE *f = fopen(filename, "w");
	if (f == NULL)
	{
		LOG(LM_MAIN, LL_ERROR, "failed to open file(%s) for saving: %s",
			filename, strerror(errno));
		res = false;
		goto bail;
	}
	size_t writeLen = strlen(ftext);
	const size_t rc = fwrite(ftext, 1, writeLen, f);
	if (rc != writeLen)
	{
		LOG(LM_MAIN, LL_ERROR, "Wrote (%d) of (%d) bytes: %s",
			(int)rc, (int)writeLen, strerror(errno));
		res = false;
		goto bail;
	}

bail:
	CFREE(text);
	CFREE(ftext);
	if (f != NULL) fclose(f);
	return res;
}
开发者ID:ChunHungLiu,项目名称:cdogs-sdl,代码行数:30,代码来源:json_utils.c

示例10: PY_pdbdata_tp_dealloc

static void PY_pdbdata_tp_dealloc(PY_pdbdata *self)
   {

/* XXX    PD_free(self->file, self->type, self->data) ;*/

/* Check if the data actually belongs to another object.
 * For example, by indexing.  In this case self->data
 * may be pointer into the middle of an array so
 * we can not delete it directly.  Instead decrement the parent.
 */
    if (self->parent == NULL)
       {if (self->data != NULL)
	   {_PP_rel_syment(self->dpobj->host_chart, self->data,
			   self->nitems, self->type);
            CFREE(self->data);};}
    else
       {Py_DECREF(self->parent);
        self->parent = NULL;
        self->data   = NULL;};

    CFREE(self->type);
    _PD_rl_dimensions(self->dims);
    _PD_rl_defstr(self->dp);
    Py_XDECREF(self->dpobj);

    PY_self_free(self);

    return;}
开发者ID:sabrown256,项目名称:pactnew,代码行数:28,代码来源:pdbdata.c

示例11: TrySaveJSONFile

bool TrySaveJSONFile(json_t *node, const char *filename)
{
	bool res = true;
	char *text;
	json_tree_to_string(node, &text);
	char *ftext = json_format_string(text);
	FILE *f = fopen(filename, "w");
	if (f == NULL)
	{
		printf("failed to open. Reason: [%s].\n", strerror(errno));
		res = false;
		goto bail;
	}
	size_t writeLen = strlen(ftext);
	const size_t rc = fwrite(ftext, 1, writeLen, f);
	if (rc != writeLen)
	{
		printf("Wrote (%d) of (%d) bytes. Reason: [%s].\n",
			(int)rc, (int)writeLen, strerror(errno));
		res = false;
		goto bail;
	}

bail:
	CFREE(text);
	CFREE(ftext);
	if (f != NULL) fclose(f);
	return res;
}
开发者ID:FlyingTarrasque,项目名称:cdogs-sdl,代码行数:29,代码来源:map_archive.c

示例12: VisitedNodesDestroy

static inline void VisitedNodesDestroy(VisitedNodes visitedNodes)
{
    CFREE(visitedNodes->nodeRecordsIndex);
	CFREE(visitedNodes->nodeRecords);
	CFREE(visitedNodes->openNodes);
	CFREE(visitedNodes);
}
开发者ID:ChunHungLiu,项目名称:cdogs-sdl,代码行数:7,代码来源:AStar.c

示例13: MenuSystemTerminate

void MenuSystemTerminate(MenuSystem *ms)
{
	MenuDestroySubmenus(ms->root);
	CFREE(ms->root);
	CFREE(ms->customDisplayFuncs);
	CFREE(ms->customDisplayDatas);
	memset(ms, 0, sizeof *ms);
}
开发者ID:MrDesTinY,项目名称:cdogs-sdl,代码行数:8,代码来源:menu.c

示例14: makeh

static void makeh(void)
   {int i, j, l, sz, change, N_var;
    double t1, t2, *tt, **td, *pd, *time, **ldata;
    haelem **tab, *hp;
    source_record *sp;
    time_list *tp;
    pcons *pp, *pn;

/* order the times for each variable in srctab */
    sz    = srctab->size;
    tab   = srctab->table;
    N_var = 0;
    for (i = 0; i < sz; i++)
        for (hp = tab[i]; hp != NULL; hp = hp->next)
            {tp = (time_list *) (hp->def);
             l  = tp->length;

/* copy the list into arrays */
             tt = time = CMAKE_N(double, l);
             td = ldata = CMAKE_N(double *, l);
             for (pp = tp->list; pp != NULL; pp = pn)
                 {sp = (source_record *) pp->car;
                  *(tt++) = sp->time;
                  *(td++) = sp->data;
                  pn = (pcons *) pp->cdr;
                  CFREE(sp);
                  CFREE(pp);};

/* sort the arrays according to the times */
             change = TRUE;
             while (change)
                {change = FALSE;
                 for (j = 1; j < l; j++)
                     {t1 = time[j-1];
                      t2 = time[j];
                      if (t2 < t1)
                         {pd         = ldata[j-1];
                          ldata[j-1] = ldata[j];
                          ldata[j]   = pd;
                          time[j]    = t1;
                          time[j-1]  = t2;
                          change     = TRUE;};};};

/* write the variable and source_record array out */
             write_var(pdsf, hp->name, time, ldata, l);
             N_var++;

/* release the temporary storage for this variable */
             CFREE(time);
             CFREE(ldata);};

/* finish up */
    PD_write(pdsf, "n_variables", "integer", &N_var);
    PD_close(pdsf);
    pdsf = NULL;    

    return;}
开发者ID:sabrown256,项目名称:pactnew,代码行数:57,代码来源:scmd.c

示例15: PlayerListTerminate

static void PlayerListTerminate(GameLoopData *data)
{
	PlayerList *pl = data->Data;

	CArrayTerminate(&pl->playerUIDs);
	MenuSystemTerminate(&pl->ms);
	CFREE(pl->data);
	CFREE(pl);
}
开发者ID:cxong,项目名称:cdogs-sdl,代码行数:9,代码来源:screens_end.c


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