STATIC_INIT(Registry_check_##id) \
{ \
/* Note: SHA256 isn't always available, use MD4 instead */ \
- string s = ""; \
- FOREACH(id, true, s = strcat(s, ":", it.registered_id)); \
+ string s = "", group = ""; \
+ int str_len = 0, digests_len = 0, group_idx = 0; \
+ FOREACH(id, true, { \
+ group = strcat(group, ":", it.registered_id); \
+ if (++group_idx < 50) /* this is to reduce strlen calls */ \
+ continue; \
+ int group_len = strlen(group); \
+ if (str_len + 1 + group_len >= 16383) /* exceeding max string length? */ \
+ { \
+ /* keep previous digests and replace current string with its digest */ \
+ s = strcat(substring(s, 0, digests_len), ":", digest_hex("MD4", s)); \
+ digests_len = str_len = strlen(s); \
+ } \
+ s = strcat(s, group); \
+ str_len += group_len; \
+ group = ""; \
+ group_idx = 0; \
+ }); \
+ s = strcat(s, group); \
s = substring(s, 1, -1); /* remove initial ":" */ \
string h = REGISTRY_HASH(id) = strzone(digest_hex("MD4", s)); \
LOG_DEBUGF(#id ": %s\n[%s]", h, s); \