From bbe4560b180e8c432c7eb7f53664605390bf67ca Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 1 Sep 2008 20:01:41 -0700 Subject: 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. --- src/utils.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/utils.h') 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 -- cgit v1.2.3