本文整理匯總了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);
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;}
示例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;
}
示例12: VisitedNodesDestroy
static inline void VisitedNodesDestroy(VisitedNodes visitedNodes)
{
CFREE(visitedNodes->nodeRecordsIndex);
CFREE(visitedNodes->nodeRecords);
CFREE(visitedNodes->openNodes);
CFREE(visitedNodes);
}
示例13: MenuSystemTerminate
void MenuSystemTerminate(MenuSystem *ms)
{
MenuDestroySubmenus(ms->root);
CFREE(ms->root);
CFREE(ms->customDisplayFuncs);
CFREE(ms->customDisplayDatas);
memset(ms, 0, sizeof *ms);
}
示例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;}
示例15: PlayerListTerminate
static void PlayerListTerminate(GameLoopData *data)
{
PlayerList *pl = data->Data;
CArrayTerminate(&pl->playerUIDs);
MenuSystemTerminate(&pl->ms);
CFREE(pl->data);
CFREE(pl);
}