diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-04 02:12:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-04 02:12:57 +0400 |
commit | 6972e19fd55470700618174bbba5893d53b1deaa (patch) | |
tree | 51f3fcbd3fa978e9053c9a0763f15232e08ff8ed /source/blender/blenkernel/intern | |
parent | 84df85164d4d869d0830ea23467bcd0e1f127d48 (diff) |
code cleanup:
- replace (strcmp(vfont->name, FO_BUILTIN_NAME) == 0) with (BKE_vfont_is_builtin(vfont)).
- reduce some double promotions.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 37 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/packedFile.c | 15 |
3 files changed, 31 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 8dd3b3da705..d92c4ca8632 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2793,7 +2793,7 @@ void CustomData_set_layer_unique_name(CustomData *data, int index) BLI_uniquename_cb(customdata_unique_check, &data_arg, typeInfo->defaultname, '.', nlayer->name, sizeof(nlayer->name)); } -void CustomData_validate_layer_name(const CustomData *data, int type, char *name, char *outname) +void CustomData_validate_layer_name(const CustomData *data, int type, const char *name, char *outname) { int index = -1; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 1ea8291adb1..74a8751b26a 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -64,11 +64,11 @@ static ListBase ttfdata = {NULL, NULL}; /* The vfont code */ -void BKE_vfont_free_data(struct VFont *vf) +void BKE_vfont_free_data(struct VFont *vfont) { - if (vf->data) { - while (vf->data->characters.first) { - VChar *che = vf->data->characters.first; + if (vfont->data) { + while (vfont->data->characters.first) { + VChar *che = vfont->data->characters.first; while (che->nurbsbase.first) { Nurb *nu = che->nurbsbase.first; @@ -76,14 +76,14 @@ void BKE_vfont_free_data(struct VFont *vf) BLI_freelinkN(&che->nurbsbase, nu); } - BLI_freelinkN(&vf->data->characters, che); + BLI_freelinkN(&vfont->data->characters, che); } - MEM_freeN(vf->data); - vf->data = NULL; + MEM_freeN(vfont->data); + vfont->data = NULL; } - BKE_vfont_tmpfont_remove(vf); + BKE_vfont_tmpfont_remove(vfont); } void BKE_vfont_free(struct VFont *vf) @@ -101,6 +101,11 @@ void BKE_vfont_free(struct VFont *vf) static void *builtin_font_data = NULL; static int builtin_font_size = 0; +int BKE_vfont_is_builtin(struct VFont *vfont) +{ + return (strcmp(vfont->name, FO_BUILTIN_NAME) == 0); +} + void BKE_vfont_builtin_register(void *mem, int size) { builtin_font_data = mem; @@ -185,7 +190,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (!vfont->data) { PackedFile *pf; - if (strcmp(vfont->name, FO_BUILTIN_NAME) == 0) { + if (BKE_vfont_is_builtin(vfont)) { pf = get_builtin_packedfile(); } else { @@ -324,11 +329,13 @@ static VFont *which_vfont(Curve *cu, CharInfo *info) VFont *BKE_vfont_builtin_get(void) { - VFont *vf; + VFont *vfont; - for (vf = G.main->vfont.first; vf; vf = vf->id.next) - if (strcmp(vf->name, FO_BUILTIN_NAME) == 0) - return vf; + for (vfont = G.main->vfont.first; vfont; vfont = vfont->id.next) { + if (BKE_vfont_is_builtin(vfont)) { + return vfont; + } + } return BKE_vfont_load(G.main, FO_BUILTIN_NAME); } @@ -663,10 +670,10 @@ makebreak: /* * The character wasn't in the current curve base so load it - * But if the font is FO_BUILTIN_NAME then do not try loading since + * But if the font is built-in then do not try loading since * whole font is in the memory already */ - if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { + if (che == NULL && BKE_vfont_is_builtin(vfont) == FALSE) { BLI_vfontchar_from_freetypefont(vfont, ascii); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 52acbeb94e5..f115a41d419 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -50,13 +50,14 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" +#include "BKE_font.h" #include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_sound.h" #include "BKE_image.h" +#include "BKE_main.h" #include "BKE_packedFile.h" #include "BKE_report.h" +#include "BKE_sound.h" +#include "BKE_utildefines.h" #ifdef _WIN32 #define open _open @@ -219,7 +220,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char void packAll(Main *bmain, ReportList *reports) { Image *ima; - VFont *vf; + VFont *vfont; bSound *sound; for (ima = bmain->image.first; ima; ima = ima->id.next) { @@ -233,9 +234,9 @@ void packAll(Main *bmain, ReportList *reports) } } - for (vf = bmain->vfont.first; vf; vf = vf->id.next) - if (vf->packedfile == NULL && vf->id.lib == NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0) - vf->packedfile = newPackedFile(reports, vf->name, bmain->name); + for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) + if (vfont->packedfile == NULL && vfont->id.lib == NULL && BKE_vfont_is_builtin(vfont) == FALSE) + vfont->packedfile = newPackedFile(reports, vfont->name, bmain->name); for (sound = bmain->sound.first; sound; sound = sound->id.next) if (sound->packedfile == NULL && sound->id.lib == NULL) |