Browse Source

cast malloc return type

So that the headers can be used from a C++ program.
master
Christophe Massiot 10 years ago
parent
commit
f972046942
3 changed files with 8 additions and 8 deletions
  1. +4
    -4
      dvb/si/strings.h
  2. +3
    -3
      mpeg/psi/psi.h
  3. +1
    -1
      mpeg/ts.h

+ 4
- 4
dvb/si/strings.h View File

@ -109,7 +109,7 @@ static inline uint8_t *dvb_string_set(const uint8_t *p_string, size_t i_length,
for (i = 0; ppsz_dvb_encodings[i] != NULL; i++) { for (i = 0; ppsz_dvb_encodings[i] != NULL; i++) {
if (!strcasecmp(psz_encoding, ppsz_dvb_encodings[i])) { if (!strcasecmp(psz_encoding, ppsz_dvb_encodings[i])) {
uint8_t *p_encoded = malloc(i_length + 1);
uint8_t *p_encoded = (uint8_t *)malloc(i_length + 1);
*pi_out_length = i_length + 1; *pi_out_length = i_length + 1;
p_encoded[0] = i; p_encoded[0] = i;
memcpy(p_encoded + 1, p_string, i_length); memcpy(p_encoded + 1, p_string, i_length);
@ -119,7 +119,7 @@ static inline uint8_t *dvb_string_set(const uint8_t *p_string, size_t i_length,
for (i = 0; ppsz_dvb_encodings10[i] != NULL; i++) { for (i = 0; ppsz_dvb_encodings10[i] != NULL; i++) {
if (!strcasecmp(psz_encoding, ppsz_dvb_encodings10[i])) { if (!strcasecmp(psz_encoding, ppsz_dvb_encodings10[i])) {
uint8_t *p_encoded = malloc(i_length + 3);
uint8_t *p_encoded = (uint8_t *)malloc(i_length + 3);
*pi_out_length = i_length + 3; *pi_out_length = i_length + 3;
p_encoded[0] = 0x10; p_encoded[0] = 0x10;
p_encoded[1] = 0x0; p_encoded[1] = 0x0;
@ -142,7 +142,7 @@ static inline char *dvb_string_get(const uint8_t *p_string, size_t i_length,
&i_length); &i_length);
if (psz_encoding == NULL || !i_length) { if (psz_encoding == NULL || !i_length) {
/* try one-byte charset */ /* try one-byte charset */
char *psz_string = malloc(i_length + 1);
char *psz_string = (uint8_t *)malloc(i_length + 1);
memcpy(psz_string, p_string, i_length); memcpy(psz_string, p_string, i_length);
psz_string[i_length] = '\0'; psz_string[i_length] = '\0';
return psz_string; return psz_string;
@ -180,7 +180,7 @@ static inline char *dvb_string_xml_escape(char *psz_input)
psz1++; psz1++;
} }
psz2 = psz_output = malloc(i_output_size + 1);
psz2 = psz_output = (uint8_t *)malloc(i_output_size + 1);
psz1 = psz_input; psz1 = psz_input;
while (*psz1) { while (*psz1) {
switch (*psz1) { switch (*psz1) {

+ 3
- 3
mpeg/psi/psi.h View File

@ -151,12 +151,12 @@ static const uint32_t p_psi_crc_table[256] = {
static inline uint8_t *psi_allocate(void) static inline uint8_t *psi_allocate(void)
{ {
return malloc((PSI_MAX_SIZE + PSI_HEADER_SIZE) * sizeof(uint8_t));
return (uint8_t *)malloc((PSI_MAX_SIZE + PSI_HEADER_SIZE) * sizeof(uint8_t));
} }
static inline uint8_t *psi_private_allocate(void) static inline uint8_t *psi_private_allocate(void)
{ {
return malloc((PSI_PRIVATE_MAX_SIZE + PSI_HEADER_SIZE) * sizeof(uint8_t));
return (uint8_t *)malloc((PSI_PRIVATE_MAX_SIZE + PSI_HEADER_SIZE) * sizeof(uint8_t));
} }
static inline void psi_set_tableid(uint8_t *p_section, uint8_t i_table_id) static inline void psi_set_tableid(uint8_t *p_section, uint8_t i_table_id)
@ -438,7 +438,7 @@ static inline void psi_split_section(uint8_t *p_ts, uint8_t *pi_ts_offset,
static inline uint8_t **psi_table_allocate(void) static inline uint8_t **psi_table_allocate(void)
{ {
return malloc(PSI_TABLE_MAX_SECTIONS * sizeof(uint8_t *));
return (uint8_t *)malloc(PSI_TABLE_MAX_SECTIONS * sizeof(uint8_t *));
} }
static inline void psi_table_init(uint8_t **pp_sections) static inline void psi_table_init(uint8_t **pp_sections)

+ 1
- 1
mpeg/ts.h View File

@ -56,7 +56,7 @@ extern "C"
static inline uint8_t *ts_allocate(void) static inline uint8_t *ts_allocate(void)
{ {
return malloc(TS_SIZE * sizeof(uint8_t));
return (uint8_t *)malloc(TS_SIZE * sizeof(uint8_t));
} }
static inline void ts_init(uint8_t *p_ts) static inline void ts_init(uint8_t *p_ts)

Loading…
Cancel
Save