Skip to content

Commit

Permalink
Fix build error with some compilers: initializer element is not a com…
Browse files Browse the repository at this point in the history
…pile-time constant
  • Loading branch information
triplef committed Jun 27, 2024
1 parent 4ae09b0 commit dbe8f19
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Source/NSKVOSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ - (bool)isEmpty
if (keyLength > 0)
{
static const char *const sc_prefix = "keyPathsForValuesAffecting";
static const size_t sc_prefixLength = 26; // strlen(sc_prefix)
static const size_t sc_bufferSize = 128;
static const size_t sc_prefixLength = strlen(sc_prefix); // 26

const char *rawKey;
size_t rawKeyLength;
SEL sel;

// max length of a key that can guaranteed fit in the char buffer,
// even if UTF16->UTF8 conversion causes length to double, or a null
// terminator is needed
static const size_t sc_safeKeyLength
= (sc_bufferSize - sc_prefixLength) / 2 - 1; // 50

const char *rawKey;
size_t rawKeyLength;
SEL sel;

rawKey = [key UTF8String];
rawKeyLength = strlen(rawKey);

Expand Down Expand Up @@ -650,7 +650,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key
if ([key length] > 0)
{
static const char *const sc_prefix = "automaticallyNotifiesObserversOf";
static const size_t sc_prefixLength = strlen(sc_prefix); // 32
static const size_t sc_prefixLength = 32; // strlen(sc_prefix)
const char *rawKey = [key UTF8String];
size_t keyLength = strlen(rawKey);
size_t bufferSize = sc_prefixLength + keyLength + 1;
Expand Down

0 comments on commit dbe8f19

Please sign in to comment.