diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-15 05:09:44 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-15 05:09:44 (GMT) |
commit | af8f9749677729fd39fd99df5779c195b4eeefed (patch) | |
tree | 9a321a234a7154c8b1228ca3ba34a87cd0dfcf6b /Python | |
parent | e76adcd78a434d7266b5fc0250be87d74dafd8df (diff) | |
download | cpython-af8f9749677729fd39fd99df5779c195b4eeefed.zip cpython-af8f9749677729fd39fd99df5779c195b4eeefed.tar.gz cpython-af8f9749677729fd39fd99df5779c195b4eeefed.tar.bz2 |
Add a note about how to do the memory deallocation a bit.
This needs a lot of work.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c index 273cf33..428b0cd 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -20,6 +20,26 @@ - syntax errors */ +/* + Note: + + You should rarely need to use the asdl_seq_free() in this file. + If you use asdl_seq_free(), you will leak any objects held in the seq. + If there is an appropriate asdl_*_seq_free() function, use it. + If there isn't an asdl_*_seq_free() function for you, you will + need to loop over the data in the sequence and free it. + + asdl_seq* seq; + int i; + + for (i = 0; i < asdl_seq_LEN(seq); i++) + free_***(asdl_seq_GET(seq, i)); + asdl_seq_free(seq); + + Almost all of the ast functions return a seq of expr, so you should + use asdl_expr_seq_free(). The exception is ast_for_suite() which + returns a seq of stmt's, so use asdl_stmt_seq_free() to free it. +*/ /* Data structure used internally */ struct compiling { |