@@ -309,9 +309,10 @@ static void build_def_props(char *buf, size_t bufsize, const CBMDefinition *def)
309309 }
310310 size_t pos = (size_t )n ;
311311 append_json_string (buf , bufsize , & pos , "docstring" , def -> docstring );
312- /* Right after the docstring: the buffer is sized for exactly these two
313- * uncapped fields (pd_props_buf), so neither can be squeezed out. */
312+ /* Right after the docstring: the buffer is sized for exactly these three
313+ * uncapped fields (pd_props_buf), so none can be squeezed out. */
314314 append_json_raw (buf , bufsize , & pos , "variants" , def -> variants );
315+ append_json_string (buf , bufsize , & pos , "variant_key" , def -> variant_key );
315316 append_json_string (buf , bufsize , & pos , "signature" , def -> signature );
316317 append_json_string (buf , bufsize , & pos , "return_type" , def -> return_type );
317318 append_json_string (buf , bufsize , & pos , "parent_class" , def -> parent_class );
@@ -353,10 +354,10 @@ static void build_def_props(char *buf, size_t bufsize, const CBMDefinition *def)
353354}
354355
355356/* A def's properties buffer: CBM_SZ_2K for every other field plus the whole
356- * serialized docstring and variants fields, which have no length cap (a field
357- * that does not fit is dropped whole). Returns `stack` for a def with neither,
358- * or when the larger buffer cannot be allocated. Twin of pass_parallel.c --
359- * keep both in sync. */
357+ * serialized docstring, variants and variant_key fields, which have no length
358+ * cap (a field that does not fit is dropped whole). Returns `stack` for a def
359+ * with none of them, or when the larger buffer cannot be allocated. Twin of
360+ * pass_parallel.c -- keep both in sync. */
360361static char * pd_props_buf (const CBMDefinition * def , char * stack , size_t * size ) {
361362 size_t need = * size ;
362363 if (def -> docstring && def -> docstring [0 ]) {
@@ -365,6 +366,10 @@ static char *pd_props_buf(const CBMDefinition *def, char *stack, size_t *size) {
365366 if (def -> variants && def -> variants [0 ]) {
366367 need += strlen ("variants" ) + strlen (def -> variants ) + PD_JSON_FIELD_OVERHEAD ;
367368 }
369+ if (def -> variant_key && def -> variant_key [0 ]) {
370+ need +=
371+ strlen ("variant_key" ) + def_json_escaped_len (def -> variant_key ) + PD_JSON_FIELD_OVERHEAD ;
372+ }
368373 if (need == * size ) {
369374 return stack ;
370375 }
0 commit comments