Skip to content

Commit 7076708

Browse files
authored
Merge pull request #3638 from ruby/document-options-lifetimes
Document lifetime of `pm_options_t`
2 parents 8c286ee + ed8f630 commit 7076708

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

include/prism.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ PRISM_EXPORTED_FUNCTION const char * pm_version(void);
4949
/**
5050
* Initialize a parser with the given start and end pointers.
5151
*
52+
* The resulting parser must eventually be freed with `pm_parser_free()`.
53+
*
5254
* @param parser The parser to initialize.
5355
* @param source The source to parse.
5456
* @param size The size of the source.
55-
* @param options The optional options to use when parsing.
57+
* @param options The optional options to use when parsing. These options must
58+
* live for the whole lifetime of this parser.
5659
*/
5760
PRISM_EXPORTED_FUNCTION void pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm_options_t *options);
5861

@@ -68,6 +71,9 @@ PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_changed_callback(pm_par
6871
/**
6972
* Free any memory associated with the given parser.
7073
*
74+
* This does not free the `pm_options_t` object that was used to initialize the
75+
* parser.
76+
*
7177
* @param parser The parser to free.
7278
*/
7379
PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser);

0 commit comments

Comments
 (0)