summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/uri.h
diff options
context:
space:
mode:
authorMichael Brown2007-05-28 19:35:15 +0200
committerMichael Brown2007-05-28 19:35:15 +0200
commit656485c1f1487775ccb0c223c4f5809f8daa7fcc (patch)
tree045b8b6e395af9b8906ce30ed6c707f0d2310db1 /src/include/gpxe/uri.h
parentMove increment/decrement debug messages to DBG2 level (diff)
downloadipxe-656485c1f1487775ccb0c223c4f5809f8daa7fcc.tar.gz
ipxe-656485c1f1487775ccb0c223c4f5809f8daa7fcc.tar.xz
ipxe-656485c1f1487775ccb0c223c4f5809f8daa7fcc.zip
Make URI structures reference-counted.
Diffstat (limited to 'src/include/gpxe/uri.h')
-rw-r--r--src/include/gpxe/uri.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/include/gpxe/uri.h b/src/include/gpxe/uri.h
index b8c7e098..6fddcc33 100644
--- a/src/include/gpxe/uri.h
+++ b/src/include/gpxe/uri.h
@@ -8,6 +8,7 @@
*/
#include <stdlib.h>
+#include <gpxe/refcnt.h>
/** A Uniform Resource Identifier
*
@@ -37,6 +38,8 @@
* query = "what=is", fragment = "this"
*/
struct uri {
+ /** Reference count */
+ struct refcnt refcnt;
/** Scheme */
const char *scheme;
/** Opaque part */
@@ -100,15 +103,25 @@ static inline int uri_has_relative_path ( struct uri *uri ) {
}
/**
- * Free URI structure
+ * Increment URI reference count
*
* @v uri URI
+ * @ret uri URI
+ */
+static inline __attribute__ (( always_inline )) struct uri *
+uri_get ( struct uri *uri ) {
+ ref_get ( &uri->refcnt );
+ return uri;
+}
+
+/**
+ * Decrement URI reference count
*
- * Frees all the dynamically-allocated storage used by the URI
- * structure.
+ * @v uri URI
*/
-static inline void free_uri ( struct uri *uri ) {
- free ( uri );
+static inline __attribute__ (( always_inline )) void
+uri_put ( struct uri *uri ) {
+ ref_put ( &uri->refcnt );
}
extern struct uri * parse_uri ( const char *uri_string );