[vlc-commits] [Git][videolan/vlc][master] freetype: darwin: avoid warning about VLA folded into array
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Sep 24 05:46:13 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
a308aa62 by Marvin Scholz at 2025-09-24T05:32:45+00:00
freetype: darwin: avoid warning about VLA folded into array
A const size_t is not quite the same as an integer constant and recently
compilers started to warn about this. We can easily avoid this by using
a define, however here we can just use the size of the array itself
and do not need to hardcode any size at all.
Avoids the following compiler warning with recent Clang:
warning: variable length array folded to constant array as an extension
- - - - -
1 changed file:
- modules/text_renderer/freetype/fonts/darwin.c
Changes:
=====================================
modules/text_renderer/freetype/fonts/darwin.c
=====================================
@@ -227,14 +227,13 @@ int CoreText_GetFamily(vlc_font_select_t *fs, const char *psz_lcname,
CFArrayRef matchedFontDescriptions = NULL;
/* we search for family name, display name and name to find them all */
- const size_t numberOfAttributes = 3;
- CTFontDescriptorRef coreTextFontDescriptors[numberOfAttributes];
- CFMutableDictionaryRef coreTextAttributes[numberOfAttributes];
- CFStringRef attributeNames[numberOfAttributes] = {
+ CFStringRef attributeNames[] = {
kCTFontFamilyNameAttribute,
kCTFontDisplayNameAttribute,
kCTFontNameAttribute,
};
+ CTFontDescriptorRef coreTextFontDescriptors[ARRAY_SIZE(attributeNames)];
+ CFMutableDictionaryRef coreTextAttributes[ARRAY_SIZE(attributeNames)];
#ifndef NDEBUG
msg_Dbg(fs->p_obj, "Creating new family for '%s'", psz_lcname);
@@ -243,7 +242,7 @@ int CoreText_GetFamily(vlc_font_select_t *fs, const char *psz_lcname,
CFStringRef familyName = CFStringCreateWithCString(kCFAllocatorDefault,
psz_lcname,
kCFStringEncodingUTF8);
- for (size_t x = 0; x < numberOfAttributes; x++) {
+ for (size_t x = 0; x < ARRAY_SIZE(attributeNames); x++) {
coreTextAttributes[x] = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, NULL);
CFDictionaryAddValue(coreTextAttributes[x], attributeNames[x], familyName);
coreTextFontDescriptors[x] = CTFontDescriptorCreateWithAttributes(coreTextAttributes[x]);
@@ -251,7 +250,7 @@ int CoreText_GetFamily(vlc_font_select_t *fs, const char *psz_lcname,
CFArrayRef coreTextFontDescriptorsArray = CFArrayCreate(kCFAllocatorDefault,
(const void **)&coreTextFontDescriptors,
- numberOfAttributes, NULL);
+ ARRAY_SIZE(attributeNames), NULL);
coreTextFontCollection = CTFontCollectionCreateWithFontDescriptors(coreTextFontDescriptorsArray, 0);
if (coreTextFontCollection == NULL) {
@@ -306,7 +305,7 @@ end:
CFRelease(coreTextFontCollection);
}
- for (size_t x = 0; x < numberOfAttributes; x++) {
+ for (size_t x = 0; x < ARRAY_SIZE(attributeNames); x++) {
CFRelease(coreTextAttributes[x]);
CFRelease(coreTextFontDescriptors[x]);
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a308aa62a75a2bec543e4c17d08c3579fc01a2bc
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a308aa62a75a2bec543e4c17d08c3579fc01a2bc
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list