Browse Source

Clarify behaviour of plug() by using intf_put() and intf_get().

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
a90a9adbd7
2 changed files with 22 additions and 3 deletions
  1. 2
    3
      src/core/interface.c
  2. 20
    0
      src/include/gpxe/interface.h

+ 2
- 3
src/core/interface.c View File

38
  * interface into a null interface.
38
  * interface into a null interface.
39
  */
39
  */
40
 void plug ( struct interface *intf, struct interface *dest ) {
40
 void plug ( struct interface *intf, struct interface *dest ) {
41
-	ref_put ( intf->dest->refcnt );
42
-	intf->dest = dest;
43
-	ref_get ( intf->dest->refcnt );
41
+	intf_put ( intf->dest );
42
+	intf->dest = intf_get ( dest );
44
 }
43
 }
45
 
44
 
46
 /**
45
 /**

+ 20
- 0
src/include/gpxe/interface.h View File

28
 	struct refcnt *refcnt;
28
 	struct refcnt *refcnt;
29
 };
29
 };
30
 
30
 
31
+/**
32
+ * Increment reference count on an interface
33
+ *
34
+ * @v intf		Interface
35
+ * @ret intf		Interface
36
+ */
37
+static inline struct interface * intf_get ( struct interface *intf ) {
38
+	ref_get ( intf->refcnt );
39
+	return intf;
40
+}
41
+
42
+/**
43
+ * Decrement reference count on an interface
44
+ *
45
+ * @v intf		Interface
46
+ */
47
+static inline void intf_put ( struct interface *intf ) {
48
+	ref_put ( intf->refcnt );
49
+}
50
+
31
 extern void plug ( struct interface *intf, struct interface *dest );
51
 extern void plug ( struct interface *intf, struct interface *dest );
32
 extern void plug_plug ( struct interface *a, struct interface *b );
52
 extern void plug_plug ( struct interface *a, struct interface *b );
33
 
53
 

Loading…
Cancel
Save