Make get_xx functions const

This commit is contained in:
bnnm 2020-07-17 19:09:47 +02:00
parent 396bfd630a
commit 7592e72bae
4 changed files with 31 additions and 31 deletions

View File

@ -29,8 +29,8 @@ struct dsp_header {
/* read the above struct; returns nonzero on failure */ /* read the above struct; returns nonzero on failure */
static int read_dsp_header_endian(struct dsp_header *header, off_t offset, STREAMFILE *streamFile, int big_endian) { static int read_dsp_header_endian(struct dsp_header *header, off_t offset, STREAMFILE *streamFile, int big_endian) {
int32_t (*get_32bit)(uint8_t *) = big_endian ? get_32bitBE : get_32bitLE; int32_t (*get_32bit)(const uint8_t *) = big_endian ? get_32bitBE : get_32bitLE;
int16_t (*get_16bit)(uint8_t *) = big_endian ? get_16bitBE : get_16bitLE; int16_t (*get_16bit)(const uint8_t *) = big_endian ? get_16bitBE : get_16bitLE;
int i; int i;
uint8_t buf[0x4e]; uint8_t buf[0x4e];

View File

@ -23,8 +23,8 @@ VGMSTREAM * init_vgmstream_redspark(STREAMFILE *streamFile) {
uint32_t key; uint32_t key;
enum {encsize = 0x1000}; enum {encsize = 0x1000};
uint8_t buf[encsize]; uint8_t buf[encsize];
int32_t(*get_32bit)(uint8_t *p) = NULL; int32_t(*get_32bit)(const uint8_t *p) = NULL;
int16_t(*get_16bit)(uint8_t *p) = NULL; int16_t(*get_16bit)(const uint8_t *p) = NULL;
get_16bit = get_16bitBE; get_16bit = get_16bitBE;
get_32bit = get_32bitBE; get_32bit = get_32bitBE;

View File

@ -414,8 +414,8 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
/* get coefs */ /* get coefs */
{ {
int16_t (*read_16bit)(off_t , STREAMFILE*) = txth.coef_big_endian ? read_16bitBE : read_16bitLE; int16_t (*read_16bit)(off_t, STREAMFILE*) = txth.coef_big_endian ? read_16bitBE : read_16bitLE;
int16_t (*get_16bit)(uint8_t * p) = txth.coef_big_endian ? get_16bitBE : get_16bitLE; int16_t (*get_16bit)(const uint8_t* p) = txth.coef_big_endian ? get_16bitBE : get_16bitLE;
for (i = 0; i < vgmstream->channels; i++) { for (i = 0; i < vgmstream->channels; i++) {
if (txth.coef_mode == 0) { /* normal coefs */ if (txth.coef_mode == 0) { /* normal coefs */

View File

@ -11,55 +11,55 @@
/* host endian independent multi-byte integer reading */ /* host endian independent multi-byte integer reading */
static inline int16_t get_16bitBE(uint8_t * p) { static inline int16_t get_16bitBE(const uint8_t* p) {
return (p[0]<<8) | (p[1]); return (p[0]<<8) | (p[1]);
} }
static inline int16_t get_16bitLE(uint8_t * p) { static inline int16_t get_16bitLE(const uint8_t* p) {
return (p[0]) | (p[1]<<8); return (p[0]) | (p[1]<<8);
} }
static inline int32_t get_32bitBE(uint8_t * p) { static inline int32_t get_32bitBE(const uint8_t* p) {
return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | (p[3]); return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | (p[3]);
} }
static inline int32_t get_32bitLE(uint8_t * p) { static inline int32_t get_32bitLE(const uint8_t* p) {
return (p[0]) | (p[1]<<8) | (p[2]<<16) | (p[3]<<24); return (p[0]) | (p[1]<<8) | (p[2]<<16) | (p[3]<<24);
} }
static inline int64_t get_64bitBE(uint8_t * p) { static inline int64_t get_64bitBE(const uint8_t* p) {
return (uint64_t)(((uint64_t)p[0]<<56) | ((uint64_t)p[1]<<48) | ((uint64_t)p[2]<<40) | ((uint64_t)p[3]<<32) | ((uint64_t)p[4]<<24) | ((uint64_t)p[5]<<16) | ((uint64_t)p[6]<<8) | ((uint64_t)p[7])); return (uint64_t)(((uint64_t)p[0]<<56) | ((uint64_t)p[1]<<48) | ((uint64_t)p[2]<<40) | ((uint64_t)p[3]<<32) | ((uint64_t)p[4]<<24) | ((uint64_t)p[5]<<16) | ((uint64_t)p[6]<<8) | ((uint64_t)p[7]));
} }
static inline int64_t get_64bitLE(uint8_t * p) { static inline int64_t get_64bitLE(const uint8_t* p) {
return (uint64_t)(((uint64_t)p[0]) | ((uint64_t)p[1]<<8) | ((uint64_t)p[2]<<16) | ((uint64_t)p[3]<<24) | ((uint64_t)p[4]<<32) | ((uint64_t)p[5]<<40) | ((uint64_t)p[6]<<48) | ((uint64_t)p[7]<<56)); return (uint64_t)(((uint64_t)p[0]) | ((uint64_t)p[1]<<8) | ((uint64_t)p[2]<<16) | ((uint64_t)p[3]<<24) | ((uint64_t)p[4]<<32) | ((uint64_t)p[5]<<40) | ((uint64_t)p[6]<<48) | ((uint64_t)p[7]<<56));
} }
/* alias of the above */ /* alias of the above */
static inline int8_t get_s8 (uint8_t *p) { return ( int8_t)p[0]; } static inline int8_t get_s8 (const uint8_t* p) { return ( int8_t)p[0]; }
static inline uint8_t get_u8 (uint8_t *p) { return (uint8_t)p[0]; } static inline uint8_t get_u8 (const uint8_t* p) { return (uint8_t)p[0]; }
static inline int16_t get_s16le(uint8_t *p) { return ( int16_t)get_16bitLE(p); } static inline int16_t get_s16le(const uint8_t* p) { return ( int16_t)get_16bitLE(p); }
static inline uint16_t get_u16le(uint8_t *p) { return (uint16_t)get_16bitLE(p); } static inline uint16_t get_u16le(const uint8_t* p) { return (uint16_t)get_16bitLE(p); }
static inline int16_t get_s16be(uint8_t *p) { return ( int16_t)get_16bitBE(p); } static inline int16_t get_s16be(const uint8_t* p) { return ( int16_t)get_16bitBE(p); }
static inline uint16_t get_u16be(uint8_t *p) { return (uint16_t)get_16bitBE(p); } static inline uint16_t get_u16be(const uint8_t* p) { return (uint16_t)get_16bitBE(p); }
static inline int32_t get_s32le(uint8_t *p) { return ( int32_t)get_32bitLE(p); } static inline int32_t get_s32le(const uint8_t* p) { return ( int32_t)get_32bitLE(p); }
static inline uint32_t get_u32le(uint8_t *p) { return (uint32_t)get_32bitLE(p); } static inline uint32_t get_u32le(const uint8_t* p) { return (uint32_t)get_32bitLE(p); }
static inline int32_t get_s32be(uint8_t *p) { return ( int32_t)get_32bitBE(p); } static inline int32_t get_s32be(const uint8_t* p) { return ( int32_t)get_32bitBE(p); }
static inline uint32_t get_u32be(uint8_t *p) { return (uint32_t)get_32bitBE(p); } static inline uint32_t get_u32be(const uint8_t* p) { return (uint32_t)get_32bitBE(p); }
static inline int64_t get_s64le(uint8_t *p) { return ( int64_t)get_64bitLE(p); } static inline int64_t get_s64le(const uint8_t* p) { return ( int64_t)get_64bitLE(p); }
static inline uint64_t get_u64le(uint8_t *p) { return (uint64_t)get_64bitLE(p); } static inline uint64_t get_u64le(const uint8_t* p) { return (uint64_t)get_64bitLE(p); }
static inline int64_t get_s64be(uint8_t *p) { return ( int64_t)get_64bitBE(p); } static inline int64_t get_s64be(const uint8_t* p) { return ( int64_t)get_64bitBE(p); }
static inline uint64_t get_u64be(uint8_t *p) { return (uint64_t)get_64bitBE(p); } static inline uint64_t get_u64be(const uint8_t* p) { return (uint64_t)get_64bitBE(p); }
void put_8bit(uint8_t * buf, int8_t i); void put_8bit(uint8_t* buf, int8_t i);
void put_16bitLE(uint8_t * buf, int16_t i); void put_16bitLE(uint8_t* buf, int16_t i);
void put_32bitLE(uint8_t * buf, int32_t i); void put_32bitLE(uint8_t* buf, int32_t i);
void put_16bitBE(uint8_t * buf, int16_t i); void put_16bitBE(uint8_t* buf, int16_t i);
void put_32bitBE(uint8_t * buf, int32_t i); void put_32bitBE(uint8_t* buf, int32_t i);
/* alias of the above */ //TODO: improve /* alias of the above */ //TODO: improve
#define put_u8 put_8bit #define put_u8 put_8bit