mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 13:00:39 +03:00
Make URI structures reference-counted.
This commit is contained in:
@@ -46,9 +46,6 @@ struct uri_opener {
|
||||
* @v xfer Data transfer interface
|
||||
* @v uri URI
|
||||
* @ret rc Return status code
|
||||
*
|
||||
* This method takes ownership of the URI structure, and is
|
||||
* responsible for eventually calling free_uri().
|
||||
*/
|
||||
int ( * open ) ( struct xfer_interface *xfer, struct uri *uri );
|
||||
};
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* Frees all the dynamically-allocated storage used by the URI
|
||||
* structure.
|
||||
* @ret uri URI
|
||||
*/
|
||||
static inline void free_uri ( struct uri *uri ) {
|
||||
free ( uri );
|
||||
static inline __attribute__ (( always_inline )) struct uri *
|
||||
uri_get ( struct uri *uri ) {
|
||||
ref_get ( &uri->refcnt );
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement URI reference count
|
||||
*
|
||||
* @v uri 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 );
|
||||
|
||||
Reference in New Issue
Block a user