diff options
author | Michael Brown <mcb30@ipxe.org> | 2014-02-25 14:03:40 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2014-02-26 23:34:07 +0000 |
commit | c7b69ac793b7704c09560eb6850e4ec2bd66e575 (patch) | |
tree | 26a3a7bc1f4195ee5c39bf098bc44be43c3c5bf6 /src/include | |
parent | 09b057ce841156cf8dfb8d356d36b046d875cdf4 (diff) | |
download | ipxe-c7b69ac793b7704c09560eb6850e4ec2bd66e575.zip ipxe-c7b69ac793b7704c09560eb6850e4ec2bd66e575.tar.gz ipxe-c7b69ac793b7704c09560eb6850e4ec2bd66e575.tar.bz2 |
[params] Use reference counters for form parameter lists
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ipxe/params.h | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/include/ipxe/params.h b/src/include/ipxe/params.h index d78adf5..c2d82d9 100644 --- a/src/include/ipxe/params.h +++ b/src/include/ipxe/params.h @@ -14,6 +14,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); /** A form parameter list */ struct parameters { + /** Reference count */ + struct refcnt refcnt; /** List of all parameter lists */ struct list_head list; /** Name */ @@ -32,6 +34,43 @@ struct parameter { const char *value; }; +/** + * Increment form parameter list reference count + * + * @v params Parameter list, or NULL + * @ret params Parameter list as passed in + */ +static inline __attribute__ (( always_inline )) struct parameters * +params_get ( struct parameters *params ) { + ref_get ( ¶ms->refcnt ); + return params; +} + +/** + * Decrement form parameter list reference count + * + * @v params Parameter list, or NULL + */ +static inline __attribute__ (( always_inline )) void +params_put ( struct parameters *params ) { + ref_put ( ¶ms->refcnt ); +} + +/** + * Claim ownership of form parameter list + * + * @v params Parameter list + * @ret params Parameter list + */ +static inline __attribute__ (( always_inline )) struct parameters * +claim_parameters ( struct parameters *params ) { + + /* Remove from list of parameter lists */ + list_del ( ¶ms->list ); + + return params; +} + /** Iterate over all form parameters in a list */ #define for_each_param( param, params ) \ list_for_each_entry ( (param), &(params)->entries, list ) @@ -40,7 +79,5 @@ extern struct parameters * find_parameters ( const char *name ); extern struct parameters * create_parameters ( const char *name ); extern struct parameter * add_parameter ( struct parameters *params, const char *key, const char *value ); -extern void destroy_parameters ( struct parameters *params ); -extern void claim_parameters ( struct parameters *params ); #endif /* _IPXE_PARAMS_H */ |