diff options
| author | Michael Brown | 2007-05-01 02:06:21 +0200 |
|---|---|---|
| committer | Michael Brown | 2007-05-01 02:06:21 +0200 |
| commit | a90a9adbd7f7ae53aa824c77d159f21ace1bc1f6 (patch) | |
| tree | 5e2bb67f5ffac5060ff5049063dd19e77304c47d | |
| parent | Document the fact that a zeroed-out refcounted object will behave in (diff) | |
| download | ipxe-a90a9adbd7f7ae53aa824c77d159f21ace1bc1f6.tar.gz ipxe-a90a9adbd7f7ae53aa824c77d159f21ace1bc1f6.tar.xz ipxe-a90a9adbd7f7ae53aa824c77d159f21ace1bc1f6.zip | |
Clarify behaviour of plug() by using intf_put() and intf_get().
| -rw-r--r-- | src/core/interface.c | 5 | ||||
| -rw-r--r-- | src/include/gpxe/interface.h | 20 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/core/interface.c b/src/core/interface.c index 4c420fda7..f9345de6f 100644 --- a/src/core/interface.c +++ b/src/core/interface.c @@ -38,9 +38,8 @@ * interface into a null interface. */ void plug ( struct interface *intf, struct interface *dest ) { - ref_put ( intf->dest->refcnt ); - intf->dest = dest; - ref_get ( intf->dest->refcnt ); + intf_put ( intf->dest ); + intf->dest = intf_get ( dest ); } /** diff --git a/src/include/gpxe/interface.h b/src/include/gpxe/interface.h index 59bb42692..d27ba6a53 100644 --- a/src/include/gpxe/interface.h +++ b/src/include/gpxe/interface.h @@ -28,6 +28,26 @@ struct interface { struct refcnt *refcnt; }; +/** + * Increment reference count on an interface + * + * @v intf Interface + * @ret intf Interface + */ +static inline struct interface * intf_get ( struct interface *intf ) { + ref_get ( intf->refcnt ); + return intf; +} + +/** + * Decrement reference count on an interface + * + * @v intf Interface + */ +static inline void intf_put ( struct interface *intf ) { + ref_put ( intf->refcnt ); +} + extern void plug ( struct interface *intf, struct interface *dest ); extern void plug_plug ( struct interface *a, struct interface *b ); |
