[bTSstream-devel] cast malloc return type
Christophe Massiot
git at videolan.org
Tue Mar 17 11:47:16 CET 2015
bitstream | branch: master | Christophe Massiot <cmassiot at openheadend.tv> | Tue Mar 17 11:46:28 2015 +0100| [f97204694230063c57c0988e693e395489e7b707] | committer: Christophe Massiot
cast malloc return type
So that the headers can be used from a C++ program.
> http://git.videolan.org/gitweb.cgi/bitstream.git/?a=commit;h=f97204694230063c57c0988e693e395489e7b707
---
dvb/si/strings.h | 8 ++++----
mpeg/psi/psi.h | 6 +++---
mpeg/ts.h | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dvb/si/strings.h b/dvb/si/strings.h
index 6720342..9a035bc 100644
--- a/dvb/si/strings.h
+++ b/dvb/si/strings.h
@@ -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++) {
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;
p_encoded[0] = i;
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++) {
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;
p_encoded[0] = 0x10;
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);
if (psz_encoding == NULL || !i_length) {
/* 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);
psz_string[i_length] = '\0';
return psz_string;
@@ -180,7 +180,7 @@ static inline char *dvb_string_xml_escape(char *psz_input)
psz1++;
}
- psz2 = psz_output = malloc(i_output_size + 1);
+ psz2 = psz_output = (uint8_t *)malloc(i_output_size + 1);
psz1 = psz_input;
while (*psz1) {
switch (*psz1) {
diff --git a/mpeg/psi/psi.h b/mpeg/psi/psi.h
index 56b6d59..b661ac4 100644
--- a/mpeg/psi/psi.h
+++ b/mpeg/psi/psi.h
@@ -151,12 +151,12 @@ static const uint32_t p_psi_crc_table[256] = {
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)
{
- 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)
@@ -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)
{
- 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)
diff --git a/mpeg/ts.h b/mpeg/ts.h
index 495b379..fba5e13 100644
--- a/mpeg/ts.h
+++ b/mpeg/ts.h
@@ -56,7 +56,7 @@ extern "C"
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)
More information about the biTStream-devel
mailing list