]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Remove assert from header files
authorTakashi Iwai <tiwai@suse.de>
Thu, 25 Oct 2007 13:36:03 +0000 (15:36 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 25 Oct 2007 13:36:03 +0000 (15:36 +0200)
Putting assert in the public macros isn't good idea at all.
Let's get rid of them.

Also, clean up snd*_alloca() functions to use a helper macro
instead of copy and paste.

include/asoundlib-head.h
include/control.h
include/global.h
include/hwdep.h
include/instr.h
include/mixer.h
include/pcm.h
include/rawmidi.h
include/seq.h
include/timer.h
src/mixer/simple_none.c

index 20c8a68db03ac2c662bf1cd9ccda04d61d907234..b4087def20ca2aa5e06c8769a20d006d6d4a271d 100644 (file)
@@ -33,7 +33,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
-#include <assert.h>
 #include <endian.h>
 #include <sys/poll.h>
 #include <errno.h>
index e61362d01461bce5ef970427281235a65ccf593e..8860294bbbc80ba255180c6ba770a9e8ef9899b7 100644 (file)
@@ -279,7 +279,7 @@ size_t snd_ctl_elem_id_sizeof(void);
  * \brief allocate an invalid #snd_ctl_elem_id_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_ctl_elem_id_alloca(ptr) do { assert(ptr); *ptr = (snd_ctl_elem_id_t *) alloca(snd_ctl_elem_id_sizeof()); memset(*ptr, 0, snd_ctl_elem_id_sizeof()); } while (0)
+#define snd_ctl_elem_id_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_id)
 int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr);
 void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj);
 void snd_ctl_elem_id_clear(snd_ctl_elem_id_t *obj);
@@ -302,7 +302,7 @@ size_t snd_ctl_card_info_sizeof(void);
  * \brief allocate an invalid #snd_ctl_card_info_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_ctl_card_info_alloca(ptr) do { assert(ptr); *ptr = (snd_ctl_card_info_t *) alloca(snd_ctl_card_info_sizeof()); memset(*ptr, 0, snd_ctl_card_info_sizeof()); } while (0)
+#define snd_ctl_card_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_card_info)
 int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr);
 void snd_ctl_card_info_free(snd_ctl_card_info_t *obj);
 void snd_ctl_card_info_clear(snd_ctl_card_info_t *obj);
@@ -320,7 +320,7 @@ size_t snd_ctl_event_sizeof(void);
  * \brief allocate an invalid #snd_ctl_event_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_ctl_event_alloca(ptr) do { assert(ptr); *ptr = (snd_ctl_event_t *) alloca(snd_ctl_event_sizeof()); memset(*ptr, 0, snd_ctl_event_sizeof()); } while (0)
+#define snd_ctl_event_alloca(ptr) __snd_alloca(ptr, snd_ctl_event)
 int snd_ctl_event_malloc(snd_ctl_event_t **ptr);
 void snd_ctl_event_free(snd_ctl_event_t *obj);
 void snd_ctl_event_clear(snd_ctl_event_t *obj);
@@ -332,7 +332,7 @@ size_t snd_ctl_elem_list_sizeof(void);
  * \brief allocate an invalid #snd_ctl_elem_list_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_ctl_elem_list_alloca(ptr) do { assert(ptr); *ptr = (snd_ctl_elem_list_t *) alloca(snd_ctl_elem_list_sizeof()); memset(*ptr, 0, snd_ctl_elem_list_sizeof()); } while (0)
+#define snd_ctl_elem_list_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_list)
 int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr);
 void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj);
 void snd_ctl_elem_list_clear(snd_ctl_elem_list_t *obj);
@@ -353,7 +353,7 @@ size_t snd_ctl_elem_info_sizeof(void);
  * \brief allocate an invalid #snd_ctl_elem_info_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_ctl_elem_info_alloca(ptr) do { assert(ptr); *ptr = (snd_ctl_elem_info_t *) alloca(snd_ctl_elem_info_sizeof()); memset(*ptr, 0, snd_ctl_elem_info_sizeof()); } while (0)
+#define snd_ctl_elem_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_info)
 int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr);
 void snd_ctl_elem_info_free(snd_ctl_elem_info_t *obj);
 void snd_ctl_elem_info_clear(snd_ctl_elem_info_t *obj);
@@ -408,7 +408,7 @@ size_t snd_ctl_elem_value_sizeof(void);
  * \brief allocate an invalid #snd_ctl_elem_value_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_ctl_elem_value_alloca(ptr) do { assert(ptr); *ptr = (snd_ctl_elem_value_t *) alloca(snd_ctl_elem_value_sizeof()); memset(*ptr, 0, snd_ctl_elem_value_sizeof()); } while (0)
+#define snd_ctl_elem_value_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_value)
 int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr);
 void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj);
 void snd_ctl_elem_value_clear(snd_ctl_elem_value_t *obj);
index f388e4b58dbb5963860ec781c384b054d0fbf72f..3e3680fb698cd042354f90370bedda37b1daf5a9 100644 (file)
@@ -102,6 +102,9 @@ void *snd_dlsym(void *handle, const char *name, const char *version);
 int snd_dlclose(void *handle);
 
 
+/** \brief alloca helper macro. */
+#define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0)
+
 /**
  * \brief Internal structure for an async notification client handler.
  *
index 6ff1e9025988bc0020ffc18227810da8c3fdcc6c..ab12822cf79929a6936d0968bd12d02f75046d53 100644 (file)
@@ -108,7 +108,7 @@ ssize_t snd_hwdep_read(snd_hwdep_t *hwdep, void *buffer, size_t size);
 
 size_t snd_hwdep_info_sizeof(void);
 /** allocate #snd_hwdep_info_t container on stack */
-#define snd_hwdep_info_alloca(ptr) do { assert(ptr); *ptr = (snd_hwdep_info_t *) alloca(snd_hwdep_info_sizeof()); memset(*ptr, 0, snd_hwdep_info_sizeof()); } while (0)
+#define snd_hwdep_info_alloca(ptr) __snd_alloca(ptr, snd_hwdep_info)
 int snd_hwdep_info_malloc(snd_hwdep_info_t **ptr);
 void snd_hwdep_info_free(snd_hwdep_info_t *obj);
 void snd_hwdep_info_copy(snd_hwdep_info_t *dst, const snd_hwdep_info_t *src);
@@ -122,7 +122,7 @@ void snd_hwdep_info_set_device(snd_hwdep_info_t *obj, unsigned int val);
 
 size_t snd_hwdep_dsp_status_sizeof(void);
 /** allocate #snd_hwdep_dsp_status_t container on stack */
-#define snd_hwdep_dsp_status_alloca(ptr) do { assert(ptr); *ptr = (snd_hwdep_dsp_status_t *) alloca(snd_hwdep_dsp_status_sizeof()); memset(*ptr, 0, snd_hwdep_dsp_status_sizeof()); } while (0)
+#define snd_hwdep_dsp_status_alloca(ptr) __snd_alloca(ptr, snd_hwdep_dsp_status)
 int snd_hwdep_dsp_status_malloc(snd_hwdep_dsp_status_t **ptr);
 void snd_hwdep_dsp_status_free(snd_hwdep_dsp_status_t *obj);
 void snd_hwdep_dsp_status_copy(snd_hwdep_dsp_status_t *dst, const snd_hwdep_dsp_status_t *src);
@@ -135,7 +135,7 @@ unsigned int snd_hwdep_dsp_status_get_chip_ready(const snd_hwdep_dsp_status_t *o
 
 size_t snd_hwdep_dsp_image_sizeof(void);
 /** allocate #snd_hwdep_dsp_image_t container on stack */
-#define snd_hwdep_dsp_image_alloca(ptr) do { assert(ptr); *ptr = (snd_hwdep_dsp_image_t *) alloca(snd_hwdep_dsp_image_sizeof()); memset(*ptr, 0, snd_hwdep_dsp_image_sizeof()); } while (0)
+#define snd_hwdep_dsp_image_alloca(ptr) __snd_alloca(ptr, snd_hwdep_dsp_image)
 int snd_hwdep_dsp_image_malloc(snd_hwdep_dsp_image_t **ptr);
 void snd_hwdep_dsp_image_free(snd_hwdep_dsp_image_t *obj);
 void snd_hwdep_dsp_image_copy(snd_hwdep_dsp_image_t *dst, const snd_hwdep_dsp_image_t *src);
index aac6f66739df1ac6c258194bedfefe11e6b490da..b4232d30f99557eac15f783f7ad10901ad15f639 100644 (file)
@@ -44,12 +44,8 @@ extern "C" {
 typedef struct _snd_instr_header snd_instr_header_t;
 
 size_t snd_instr_header_sizeof(void);
-#define snd_instr_header_alloca(ptr) \
-do {\
-       assert(ptr);\
-       *ptr = (snd_instr_header_t *)alloca(snd_instr_header_sizeof());\
-       memset(*ptr, 0, snd_instr_header_sizeof());\
-} while (0) /**< allocate instrument header on stack */
+/** allocate instrument header on stack */
+#define snd_instr_header_alloca(ptr) __snd_alloca(ptr, snd_instr_header)
 int snd_instr_header_malloc(snd_instr_header_t **ptr, size_t len);
 void snd_instr_header_free(snd_instr_header_t *ptr);
 void snd_instr_header_copy(snd_instr_header_t *dst, const snd_instr_header_t *src);
index 41297787d779f09d6e1c5fa8d87d3595c20f64ea..ac46b121776a9411b9d0f5909a011262fad22c3d 100644 (file)
@@ -146,7 +146,7 @@ size_t snd_mixer_class_sizeof(void);
  * \brief allocate an invalid #snd_mixer_class_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_mixer_class_alloca(ptr) do { assert(ptr); *ptr = (snd_mixer_class_t *) alloca(snd_mixer_class_sizeof()); memset(*ptr, 0, snd_mixer_class_sizeof()); } while (0)
+#define snd_mixer_class_alloca(ptr) __snd_alloca(ptr, snd_mixer_class)
 int snd_mixer_class_malloc(snd_mixer_class_t **ptr);
 void snd_mixer_class_free(snd_mixer_class_t *obj);
 void snd_mixer_class_copy(snd_mixer_class_t *dst, const snd_mixer_class_t *src);
@@ -294,7 +294,7 @@ size_t snd_mixer_selem_id_sizeof(void);
  * \brief allocate an invalid #snd_mixer_selem_id_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_mixer_selem_id_alloca(ptr) do { assert(ptr); *ptr = (snd_mixer_selem_id_t *) alloca(snd_mixer_selem_id_sizeof()); memset(*ptr, 0, snd_mixer_selem_id_sizeof()); } while (0)
+#define snd_mixer_selem_id_alloca(ptr) __snd_alloca(ptr, snd_mixer_selem_id)
 int snd_mixer_selem_id_malloc(snd_mixer_selem_id_t **ptr);
 void snd_mixer_selem_id_free(snd_mixer_selem_id_t *obj);
 void snd_mixer_selem_id_copy(snd_mixer_selem_id_t *dst, const snd_mixer_selem_id_t *src);
index db9fca358b3d11edce826771489650cefb5e3ac9..268a902e889330b827feeb4580860e58369789b4 100644 (file)
@@ -470,7 +470,7 @@ size_t snd_pcm_info_sizeof(void);
  * \brief allocate an invalid #snd_pcm_info_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_pcm_info_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_info_t *) alloca(snd_pcm_info_sizeof()); memset(*ptr, 0, snd_pcm_info_sizeof()); } while (0)
+#define snd_pcm_info_alloca(ptr) __snd_alloca(ptr, snd_pcm_info)
 int snd_pcm_info_malloc(snd_pcm_info_t **ptr);
 void snd_pcm_info_free(snd_pcm_info_t *obj);
 void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src);
@@ -548,7 +548,7 @@ size_t snd_pcm_hw_params_sizeof(void);
  * \brief allocate an invalid #snd_pcm_hw_params_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_pcm_hw_params_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_hw_params_t *) alloca(snd_pcm_hw_params_sizeof()); memset(*ptr, 0, snd_pcm_hw_params_sizeof()); } while (0)
+#define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params)
 int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr);
 void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj);
 void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src);
@@ -699,7 +699,7 @@ size_t snd_pcm_sw_params_sizeof(void);
  * \brief allocate an invalid #snd_pcm_sw_params_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_pcm_sw_params_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_sw_params_t *) alloca(snd_pcm_sw_params_sizeof()); memset(*ptr, 0, snd_pcm_sw_params_sizeof()); } while (0)
+#define snd_pcm_sw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_sw_params)
 int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr);
 void snd_pcm_sw_params_free(snd_pcm_sw_params_t *obj);
 void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src);
@@ -747,7 +747,7 @@ size_t snd_pcm_access_mask_sizeof(void);
  * \brief allocate an empty #snd_pcm_access_mask_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_pcm_access_mask_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_access_mask_t *) alloca(snd_pcm_access_mask_sizeof()); memset(*ptr, 0, snd_pcm_access_mask_sizeof()); } while (0)
+#define snd_pcm_access_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_access_mask)
 int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr);
 void snd_pcm_access_mask_free(snd_pcm_access_mask_t *obj);
 void snd_pcm_access_mask_copy(snd_pcm_access_mask_t *dst, const snd_pcm_access_mask_t *src);
@@ -772,7 +772,7 @@ size_t snd_pcm_format_mask_sizeof(void);
  * \brief allocate an empty #snd_pcm_format_mask_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_pcm_format_mask_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_format_mask_t *) alloca(snd_pcm_format_mask_sizeof()); memset(*ptr, 0, snd_pcm_format_mask_sizeof()); } while (0)
+#define snd_pcm_format_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_format_mask)
 int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr);
 void snd_pcm_format_mask_free(snd_pcm_format_mask_t *obj);
 void snd_pcm_format_mask_copy(snd_pcm_format_mask_t *dst, const snd_pcm_format_mask_t *src);
@@ -797,7 +797,7 @@ size_t snd_pcm_subformat_mask_sizeof(void);
  * \brief allocate an empty #snd_pcm_subformat_mask_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_pcm_subformat_mask_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_subformat_mask_t *) alloca(snd_pcm_subformat_mask_sizeof()); memset(*ptr, 0, snd_pcm_subformat_mask_sizeof()); } while (0)
+#define snd_pcm_subformat_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_subformat_mask)
 int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr);
 void snd_pcm_subformat_mask_free(snd_pcm_subformat_mask_t *obj);
 void snd_pcm_subformat_mask_copy(snd_pcm_subformat_mask_t *dst, const snd_pcm_subformat_mask_t *src);
@@ -822,7 +822,7 @@ size_t snd_pcm_status_sizeof(void);
  * \brief allocate an invalid #snd_pcm_status_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_pcm_status_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_status_t *) alloca(snd_pcm_status_sizeof()); memset(*ptr, 0, snd_pcm_status_sizeof()); } while (0)
+#define snd_pcm_status_alloca(ptr) __snd_alloca(ptr, snd_pcm_status)
 int snd_pcm_status_malloc(snd_pcm_status_t **ptr);
 void snd_pcm_status_free(snd_pcm_status_t *obj);
 void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src);
index c7517aa2d1848252e843df643adad89e8b24371f..1d8fd562764986c5e34213252566a7aa289a397a 100644 (file)
@@ -93,7 +93,7 @@ size_t snd_rawmidi_info_sizeof(void);
  * \brief allocate an invalid #snd_rawmidi_info_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_rawmidi_info_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_info_t *) alloca(snd_rawmidi_info_sizeof()); memset(*ptr, 0, snd_rawmidi_info_sizeof()); } while (0)
+#define snd_rawmidi_info_alloca(ptr) __snd_alloca(ptr, snd_rawmidi_info)
 int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr);
 void snd_rawmidi_info_free(snd_rawmidi_info_t *obj);
 void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src);
@@ -116,7 +116,7 @@ size_t snd_rawmidi_params_sizeof(void);
  * \brief allocate an invalid #snd_rawmidi_params_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_rawmidi_params_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_params_t *) alloca(snd_rawmidi_params_sizeof()); memset(*ptr, 0, snd_rawmidi_params_sizeof()); } while (0)
+#define snd_rawmidi_params_alloca(ptr) __snd_alloca(ptr, snd_rawmidi_params)
 int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr);
 void snd_rawmidi_params_free(snd_rawmidi_params_t *obj);
 void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src);
@@ -133,7 +133,7 @@ size_t snd_rawmidi_status_sizeof(void);
  * \brief allocate an invalid #snd_rawmidi_status_t using standard alloca
  * \param ptr returned pointer
  */
-#define snd_rawmidi_status_alloca(ptr) do { assert(ptr); *ptr = (snd_rawmidi_status_t *) alloca(snd_rawmidi_status_sizeof()); memset(*ptr, 0, snd_rawmidi_status_sizeof()); } while (0)
+#define snd_rawmidi_status_alloca(ptr) __snd_alloca(ptr, snd_rawmidi_status)
 int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr);
 void snd_rawmidi_status_free(snd_rawmidi_status_t *obj);
 void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src);
index 94ea711a63afa4a9ee6d8142155207a7a4ddf815..397a73c548a95468f76753f492086dd5b3d9441c 100644 (file)
@@ -46,15 +46,6 @@ extern "C" {
 /** Sequencer handle */
 typedef struct _snd_seq snd_seq_t;
 
-#ifndef DOC_HIDDEN
-#define SND_ALLOCA(type,ptr) \
-do {\
-       assert(ptr);\
-       *ptr = (type##_t *)alloca(type##_sizeof());\
-       memset(*ptr, 0, type##_sizeof());\
-} while (0)
-#endif
-
 /**
  * sequencer opening stream types
  */
@@ -106,7 +97,7 @@ typedef struct _snd_seq_system_info snd_seq_system_info_t;
 size_t snd_seq_system_info_sizeof(void);
 /** allocate a #snd_seq_system_info_t container on stack */
 #define snd_seq_system_info_alloca(ptr) \
-       SND_ALLOCA(snd_seq_system_info, ptr)
+       __snd_alloca(ptr, snd_seq_system_info)
 int snd_seq_system_info_malloc(snd_seq_system_info_t **ptr);
 void snd_seq_system_info_free(snd_seq_system_info_t *ptr);
 void snd_seq_system_info_copy(snd_seq_system_info_t *dst, const snd_seq_system_info_t *src);
@@ -142,7 +133,7 @@ typedef enum snd_seq_client_type {
 size_t snd_seq_client_info_sizeof(void);
 /** allocate a #snd_seq_client_info_t container on stack */
 #define snd_seq_client_info_alloca(ptr) \
-       SND_ALLOCA(snd_seq_client_info, ptr)
+       __snd_alloca(ptr, snd_seq_client_info)
 int snd_seq_client_info_malloc(snd_seq_client_info_t **ptr);
 void snd_seq_client_info_free(snd_seq_client_info_t *ptr);
 void snd_seq_client_info_copy(snd_seq_client_info_t *dst, const snd_seq_client_info_t *src);
@@ -176,7 +167,7 @@ typedef struct _snd_seq_client_pool snd_seq_client_pool_t;
 size_t snd_seq_client_pool_sizeof(void);
 /** allocate a #snd_seq_client_pool_t container on stack */
 #define snd_seq_client_pool_alloca(ptr) \
-       SND_ALLOCA(snd_seq_client_pool, ptr)
+       __snd_alloca(ptr, snd_seq_client_pool)
 int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr);
 void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr);
 void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src);
@@ -265,7 +256,7 @@ typedef struct _snd_seq_port_info snd_seq_port_info_t;
 size_t snd_seq_port_info_sizeof(void);
 /** allocate a #snd_seq_port_info_t container on stack */
 #define snd_seq_port_info_alloca(ptr) \
-       SND_ALLOCA(snd_seq_port_info, ptr)
+       __snd_alloca(ptr, snd_seq_port_info)
 int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr);
 void snd_seq_port_info_free(snd_seq_port_info_t *ptr);
 void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src);
@@ -323,7 +314,7 @@ typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t;
 size_t snd_seq_port_subscribe_sizeof(void);
 /** allocate a #snd_seq_port_subscribe_t container on stack */
 #define snd_seq_port_subscribe_alloca(ptr) \
-       SND_ALLOCA(snd_seq_port_subscribe, ptr)
+       __snd_alloca(ptr, snd_seq_port_subscribe)
 int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr);
 void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr);
 void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src);
@@ -361,7 +352,7 @@ typedef enum {
 size_t snd_seq_query_subscribe_sizeof(void);
 /** allocate a #snd_seq_query_subscribe_t container on stack */
 #define snd_seq_query_subscribe_alloca(ptr) \
-       SND_ALLOCA(snd_seq_query_subscribe, ptr)
+       __snd_alloca(ptr, snd_seq_query_subscribe)
 int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr);
 void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr);
 void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src);
@@ -411,7 +402,7 @@ typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t;
 size_t snd_seq_queue_info_sizeof(void);
 /** allocate a #snd_seq_queue_info_t container on stack */
 #define snd_seq_queue_info_alloca(ptr) \
-       SND_ALLOCA(snd_seq_queue_info, ptr)
+       __snd_alloca(ptr, snd_seq_queue_info)
 int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr);
 void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr);
 void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src);
@@ -443,7 +434,7 @@ int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used);
 size_t snd_seq_queue_status_sizeof(void);
 /** allocate a #snd_seq_queue_status_t container on stack */
 #define snd_seq_queue_status_alloca(ptr) \
-       SND_ALLOCA(snd_seq_queue_status, ptr)
+       __snd_alloca(ptr, snd_seq_queue_status)
 int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr);
 void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr);
 void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src);
@@ -461,7 +452,7 @@ int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *s
 size_t snd_seq_queue_tempo_sizeof(void);
 /** allocate a #snd_seq_queue_tempo_t container on stack */
 #define snd_seq_queue_tempo_alloca(ptr) \
-       SND_ALLOCA(snd_seq_queue_tempo, ptr)
+       __snd_alloca(ptr, snd_seq_queue_tempo)
 int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr);
 void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr);
 void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src);
@@ -492,7 +483,7 @@ typedef enum {
 size_t snd_seq_queue_timer_sizeof(void);
 /** allocate a #snd_seq_queue_timer_t container on stack */
 #define snd_seq_queue_timer_alloca(ptr) \
-       SND_ALLOCA(snd_seq_queue_timer, ptr)
+       __snd_alloca(ptr, snd_seq_queue_timer)
 int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr);
 void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr);
 void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src);
@@ -551,7 +542,7 @@ typedef struct _snd_seq_remove_events snd_seq_remove_events_t;
 size_t snd_seq_remove_events_sizeof(void);
 /** allocate a #snd_seq_remove_events_t container on stack */
 #define snd_seq_remove_events_alloca(ptr) \
-       SND_ALLOCA(snd_seq_remove_events, ptr)
+       __snd_alloca(ptr, snd_seq_remove_events)
 int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr);
 void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr);
 void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src);
index ef6a18de8e06988b51074c51c145fddc7a7295e7..4d06e31f1f01148cbdfd0db86bac7fd8e4b74b03 100644 (file)
@@ -164,7 +164,7 @@ ssize_t snd_timer_read(snd_timer_t *handle, void *buffer, size_t size);
 
 size_t snd_timer_id_sizeof(void);
 /** allocate #snd_timer_id_t container on stack */
-#define snd_timer_id_alloca(ptr) do { assert(ptr); *ptr = (snd_timer_id_t *) alloca(snd_timer_id_sizeof()); memset(*ptr, 0, snd_timer_id_sizeof()); } while (0)
+#define snd_timer_id_alloca(ptr) __snd_alloca(ptr, snd_timer_id)
 int snd_timer_id_malloc(snd_timer_id_t **ptr);
 void snd_timer_id_free(snd_timer_id_t *obj);
 void snd_timer_id_copy(snd_timer_id_t *dst, const snd_timer_id_t *src);
@@ -182,7 +182,7 @@ int snd_timer_id_get_subdevice(snd_timer_id_t *id);
 
 size_t snd_timer_ginfo_sizeof(void);
 /** allocate #snd_timer_ginfo_t container on stack */
-#define snd_timer_ginfo_alloca(ptr) do { assert(ptr); *ptr = (snd_timer_ginfo_t *) alloca(snd_timer_ginfo_sizeof()); memset(*ptr, 0, snd_timer_ginfo_sizeof()); } while (0)
+#define snd_timer_ginfo_alloca(ptr) __snd_alloca(ptr, snd_timer_ginfo)
 int snd_timer_ginfo_malloc(snd_timer_ginfo_t **ptr);
 void snd_timer_ginfo_free(snd_timer_ginfo_t *obj);
 void snd_timer_ginfo_copy(snd_timer_ginfo_t *dst, const snd_timer_ginfo_t *src);
@@ -200,7 +200,7 @@ unsigned int snd_timer_ginfo_get_clients(snd_timer_ginfo_t *obj);
 
 size_t snd_timer_info_sizeof(void);
 /** allocate #snd_timer_info_t container on stack */
-#define snd_timer_info_alloca(ptr) do { assert(ptr); *ptr = (snd_timer_info_t *) alloca(snd_timer_info_sizeof()); memset(*ptr, 0, snd_timer_info_sizeof()); } while (0)
+#define snd_timer_info_alloca(ptr) __snd_alloca(ptr, snd_timer_info)
 int snd_timer_info_malloc(snd_timer_info_t **ptr);
 void snd_timer_info_free(snd_timer_info_t *obj);
 void snd_timer_info_copy(snd_timer_info_t *dst, const snd_timer_info_t *src);
@@ -213,7 +213,7 @@ long snd_timer_info_get_resolution(snd_timer_info_t * info);
 
 size_t snd_timer_params_sizeof(void);
 /** allocate #snd_timer_params_t container on stack */
-#define snd_timer_params_alloca(ptr) do { assert(ptr); *ptr = (snd_timer_params_t *) alloca(snd_timer_params_sizeof()); memset(*ptr, 0, snd_timer_params_sizeof()); } while (0)
+#define snd_timer_params_alloca(ptr) __snd_alloca(ptr, snd_timer_params)
 int snd_timer_params_malloc(snd_timer_params_t **ptr);
 void snd_timer_params_free(snd_timer_params_t *obj);
 void snd_timer_params_copy(snd_timer_params_t *dst, const snd_timer_params_t *src);
@@ -233,7 +233,7 @@ unsigned int snd_timer_params_get_filter(snd_timer_params_t * params);
 
 size_t snd_timer_status_sizeof(void);
 /** allocate #snd_timer_status_t container on stack */
-#define snd_timer_status_alloca(ptr) do { assert(ptr); *ptr = (snd_timer_status_t *) alloca(snd_timer_status_sizeof()); memset(*ptr, 0, snd_timer_status_sizeof()); } while (0)
+#define snd_timer_status_alloca(ptr) __snd_alloca(ptr, snd_timer_status)
 int snd_timer_status_malloc(snd_timer_status_t **ptr);
 void snd_timer_status_free(snd_timer_status_t *obj);
 void snd_timer_status_copy(snd_timer_status_t *dst, const snd_timer_status_t *src);
index 7e7af7b5b817056c23eb4fd2e427bc9dbfcc0db1..6b015af138cb7ea0527ad1f3b4852f81bbf3fc57 100644 (file)
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
+#include <assert.h>
 #include <math.h>
 #include <alsa/asoundlib.h>
 #include "mixer_simple.h"