mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 18:09:59 +00:00
SF_CUES: Work around Clang mis-feature
For some reason Clang refuses to calculate `sizeof (SF_CUES_VAR (1))` so we have to manually bodgy our way around this.
This commit is contained in:
parent
9ea30b4c19
commit
1f1b9de462
17
src/common.c
17
src/common.c
@ -1185,9 +1185,20 @@ psf_memset (void *s, int c, sf_count_t len)
|
||||
return s ;
|
||||
} /* psf_memset */
|
||||
|
||||
|
||||
/*
|
||||
** Clang refuses to do sizeof (SF_CUES_VAR (cue_count)) so we have to manually
|
||||
** bodgy something up instead.
|
||||
*/
|
||||
|
||||
typedef SF_CUES_VAR (1) SF_CUES_1 ;
|
||||
typedef SF_CUES_VAR (2) SF_CUES_2 ;
|
||||
|
||||
#define SF_CUES_VAR_SIZE(count) (sizeof (SF_CUES_1) + count * (sizeof (SF_CUES_2) - sizeof (SF_CUES_1)))
|
||||
|
||||
SF_CUES *
|
||||
psf_cues_alloc (uint32_t cue_count)
|
||||
{ SF_CUES *pcues = calloc (1, sizeof (SF_CUES_VAR (cue_count))) ;
|
||||
{ SF_CUES *pcues = calloc (1, SF_CUES_VAR_SIZE (cue_count)) ;
|
||||
|
||||
pcues->cue_count = cue_count ;
|
||||
return pcues ;
|
||||
@ -1198,7 +1209,7 @@ psf_cues_dup (const void * ptr)
|
||||
{ const SF_CUES *pcues = ptr ;
|
||||
SF_CUES *pnew = psf_cues_alloc (pcues->cue_count) ;
|
||||
|
||||
memcpy (pnew, pcues, sizeof (SF_CUES_VAR (pcues->cue_count))) ;
|
||||
memcpy (pnew, pcues, SF_CUES_VAR_SIZE (pcues->cue_count)) ;
|
||||
return pnew ;
|
||||
} /* psf_cues_dup */
|
||||
|
||||
@ -1209,7 +1220,7 @@ psf_get_cues (SF_PRIVATE * psf, void * data, size_t datasize)
|
||||
{ uint32_t cue_count = (datasize - sizeof (uint32_t)) / sizeof (SF_CUE_POINT) ;
|
||||
|
||||
cue_count = SF_MIN (cue_count, psf->cues->cue_count) ;
|
||||
memcpy (data, psf->cues, sizeof (SF_CUES_VAR (cue_count))) ;
|
||||
memcpy (data, psf->cues, SF_CUES_VAR_SIZE (cue_count)) ;
|
||||
((SF_CUES*) data)->cue_count = cue_count ;
|
||||
} ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user