pcm_byteswap: converted NULL checks to assertions

It is illegal to pass a NULL buffer to pcm_byteswap_X().  The result
of this is that pcm_byteswap_X() never returns NULL.
This commit is contained in:
Max Kellermann 2009-07-22 19:04:38 +02:00
parent c5a662f405
commit 172a1dbdb9
2 changed files with 5 additions and 10 deletions

View File

@ -38,8 +38,7 @@ const int16_t *pcm_byteswap_16(struct pcm_buffer *buffer,
unsigned i; unsigned i;
int16_t *buf = pcm_buffer_get(buffer, len); int16_t *buf = pcm_buffer_get(buffer, len);
if (!buf) assert(buf != NULL);
return NULL;
for (i = 0; i < len / 2; i++) for (i = 0; i < len / 2; i++)
buf[i] = swab16(src[i]); buf[i] = swab16(src[i]);
@ -61,8 +60,7 @@ const int32_t *pcm_byteswap_32(struct pcm_buffer *buffer,
unsigned i; unsigned i;
int32_t *buf = pcm_buffer_get(buffer, len); int32_t *buf = pcm_buffer_get(buffer, len);
if (!buf) assert(buf != NULL);
return NULL;
for (i = 0; i < len / 4; i++) for (i = 0; i < len / 4; i++)
buf[i] = swab32(src[i]); buf[i] = swab32(src[i]);

View File

@ -88,8 +88,7 @@ pcm_convert_16(struct pcm_convert_state *state,
if (dest_format->reverse_endian) { if (dest_format->reverse_endian) {
buf = pcm_byteswap_16(&state->byteswap_buffer, buf, len); buf = pcm_byteswap_16(&state->byteswap_buffer, buf, len);
if (!buf) assert(buf != NULL);
g_error("pcm_byteswap_16() failed");
} }
*dest_size_r = len; *dest_size_r = len;
@ -131,8 +130,7 @@ pcm_convert_24(struct pcm_convert_state *state,
if (dest_format->reverse_endian) { if (dest_format->reverse_endian) {
buf = pcm_byteswap_32(&state->byteswap_buffer, buf, len); buf = pcm_byteswap_32(&state->byteswap_buffer, buf, len);
if (!buf) assert(buf != NULL);
g_error("pcm_byteswap_32() failed");
} }
*dest_size_r = len; *dest_size_r = len;
@ -174,8 +172,7 @@ pcm_convert_32(struct pcm_convert_state *state,
if (dest_format->reverse_endian) { if (dest_format->reverse_endian) {
buf = pcm_byteswap_32(&state->byteswap_buffer, buf, len); buf = pcm_byteswap_32(&state->byteswap_buffer, buf, len);
if (!buf) assert(buf != NULL);
g_error("pcm_byteswap_32() failed");
} }
*dest_size_r = len; *dest_size_r = len;