diff options
author | 2002-04-22 16:41:54 +0000 | |
---|---|---|
committer | 2002-04-22 16:41:54 +0000 | |
commit | aade6be79c02efd191409e41b5cdf35bb53cb9fc (patch) | |
tree | ba95001377724f83857035a50aafa6fc1f4ffb5d /share/man/man3 | |
parent | Uncommit. Since this came out of the blue, without anyone else having (diff) | |
download | wireguard-openbsd-aade6be79c02efd191409e41b5cdf35bb53cb9fc.tar.xz wireguard-openbsd-aade6be79c02efd191409e41b5cdf35bb53cb9fc.zip |
fix example showing how to properly free a tree; pointed out by dugsong@
Diffstat (limited to 'share/man/man3')
-rw-r--r-- | share/man/man3/tree.3 | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3 index 4683a2a9653..897a405444b 100644 --- a/share/man/man3/tree.3 +++ b/share/man/man3/tree.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tree.3,v 1.4 2002/04/08 21:07:54 dugsong Exp $ +.\" $OpenBSD: tree.3,v 1.5 2002/04/22 16:41:54 provos Exp $ .\"/* .\" * Copyright 2002 Niels Provos <provos@citi.umich.edu> .\" * All rights reserved. @@ -412,8 +412,10 @@ macro should be used to check whether a splay tree is empty. .Sh NOTES Trying to free a tree in the following way is a common error: .Bd -literal -offset indent -SPLAY_FOREACH(var, NAME, head) +SPLAY_FOREACH(var, NAME, head) { + SPLAY_REMOVE(NAME, head, var); free(var); +} free(head); .Ed .Pp @@ -426,6 +428,7 @@ Proper code needs a second variable. .Bd -literal -offset indent for (var = SPLAY_MIN(NAME, head); var != NULL; var = nxt) { nxt = SPLAY_NEXT(NAME, head, var); + SPLAY_REMOVE(NAME, head, var); free(var); } .Ed |