diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-01 20:01:41 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-01 20:07:50 -0700 |
commit | bbe4560b180e8c432c7eb7f53664605390bf67ca (patch) | |
tree | 38a4f310408726002c9b0a89b51d6684bc604265 | |
parent | 36984e9e8c7ccb33f43a9f096e848d28e532dc6e (diff) | |
download | mpd-bbe4560b180e8c432c7eb7f53664605390bf67ca.tar.gz mpd-bbe4560b180e8c432c7eb7f53664605390bf67ca.tar.xz mpd-bbe4560b180e8c432c7eb7f53664605390bf67ca.zip |
provide a generic deconst_ptr function
This is generic enough to be used for various purposes. It will
only deconst their argument to work around various braindead
APIs without having to write a new wrapper each time we use one
of those braindead APIs. It does not cast nor do do anything
other than quietly remove the const qualifier for those
braindead APIs.
-rw-r--r-- | src/utils.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h index 6a6e562cf..0001ba3c8 100644 --- a/src/utils.h +++ b/src/utils.h @@ -90,4 +90,15 @@ void xpthread_mutex_destroy(pthread_mutex_t *mutex); void xpthread_cond_destroy(pthread_cond_t *cond); +/* + * Work-arounds for braindead APIs that require non-const pointers: + * ao_play(), free(), vorbis_comment_add_tag(), iconv() + */ +static inline void * deconst_ptr(const void *ptr) +{ + union { const void *in; void *out; } u; + u.in = ptr; + return u.out; +} + #endif |