Sfoglia il codice sorgente

Make ref_get() return the reference, for cleaner code.

tags/v0.9.3
Michael Brown 17 anni fa
parent
commit
ed20fee0cf
2 ha cambiato i file con 9 aggiunte e 9 eliminazioni
  1. 8
    8
      src/core/refcnt.c
  2. 1
    1
      src/include/gpxe/refcnt.h

+ 8
- 8
src/core/refcnt.c Vedi File

@@ -29,18 +29,18 @@
29 29
  * Increment reference count
30 30
  *
31 31
  * @v refcnt		Reference counter, or NULL
32
+ * @ret refcnt		Reference counter
32 33
  *
33 34
  * If @c refcnt is NULL, no action is taken.
34 35
  */
35
-void ref_get ( struct refcnt *refcnt ) {
36
+struct refcnt * ref_get ( struct refcnt *refcnt ) {
36 37
 
37
-	if ( ! refcnt )
38
-		return;
39
-
40
-	refcnt->refcnt++;
41
-
42
-	DBGC2 ( refcnt, "REFCNT %p incremented to %d\n",
43
-		refcnt, refcnt->refcnt );
38
+	if ( refcnt ) {
39
+		refcnt->refcnt++;
40
+		DBGC2 ( refcnt, "REFCNT %p incremented to %d\n",
41
+			refcnt, refcnt->refcnt );
42
+	}
43
+	return refcnt;
44 44
 }
45 45
 
46 46
 /**

+ 1
- 1
src/include/gpxe/refcnt.h Vedi File

@@ -38,7 +38,7 @@ struct refcnt {
38 38
 	void ( * free ) ( struct refcnt *refcnt );
39 39
 };
40 40
 
41
-extern void ref_get ( struct refcnt *refcnt );
41
+extern struct refcnt * ref_get ( struct refcnt *refcnt );
42 42
 extern void ref_put ( struct refcnt *refcnt );
43 43
 
44 44
 #endif /* _GPXE_REFCNT_H */

Loading…
Annulla
Salva