diff options
author | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2013-01-23 04:21:35 +0400 |
---|---|---|
committer | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2013-01-23 04:21:35 +0400 |
commit | fa53618fa6c017dd5d257f45ec878f6f26fba3d7 (patch) | |
tree | 626ba1d1b5c619ee058be1ddba1636728a69c814 /misc | |
parent | c7d42bc280ad0ef0be91ba0a7c750dbfa3e8dc49 (diff) |
fix some pointer casts which are invalid in C++, to get compiling with MSVC working again
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cstring.h | 2 | ||||
-rw-r--r-- | misc/read_file.h | 4 | ||||
-rw-r--r-- | misc/read_write_int.h | 32 |
3 files changed, 19 insertions, 19 deletions
diff --git a/misc/cstring.h b/misc/cstring.h index 561a5fd..bd8de75 100644 --- a/misc/cstring.h +++ b/misc/cstring.h @@ -335,7 +335,7 @@ static char * b_cstring_strdup (b_cstring cstr, size_t offset, size_t length) return NULL; } - char *buf = BAlloc(length + 1); + char *buf = (char *)BAlloc(length + 1); if (buf) { b_cstring_copy_to_buf(cstr, offset, length, buf); buf[length] = '\0'; diff --git a/misc/read_file.h b/misc/read_file.h index a19456e..e1862e5 100644 --- a/misc/read_file.h +++ b/misc/read_file.h @@ -49,7 +49,7 @@ static int read_file (const char *file, uint8_t **out_data, size_t *out_len) size_t buf_len = 0; size_t buf_size = 128; - uint8_t *buf = malloc(buf_size); + uint8_t *buf = (uint8_t *)malloc(buf_size); if (!buf) { goto fail1; } @@ -61,7 +61,7 @@ static int read_file (const char *file, uint8_t **out_data, size_t *out_len) } size_t newsize = 2 * buf_size; - uint8_t *newbuf = realloc(buf, newsize); + uint8_t *newbuf = (uint8_t *)realloc(buf, newsize); if (!newbuf) { goto fail; } diff --git a/misc/read_write_int.h b/misc/read_write_int.h index b2cee00..bc4ed2c 100644 --- a/misc/read_write_int.h +++ b/misc/read_write_int.h @@ -54,26 +54,26 @@ static void badvpn_write_be64 (uint64_t x, char *c_ptr); static uint8_t badvpn_read_le8 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint8_t)ptr[0] << 0); } static uint16_t badvpn_read_le16 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint16_t)ptr[1] << 8) | ((uint16_t)ptr[0] << 0); } static uint32_t badvpn_read_le32 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint32_t)ptr[3] << 24) | ((uint32_t)ptr[2] << 16) | ((uint32_t)ptr[1] << 8) | ((uint32_t)ptr[0] << 0); } static uint64_t badvpn_read_le64 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint64_t)ptr[7] << 56) | ((uint64_t)ptr[6] << 48) | ((uint64_t)ptr[5] << 40) | ((uint64_t)ptr[4] << 32) | ((uint64_t)ptr[3] << 24) | ((uint64_t)ptr[2] << 16) | @@ -82,26 +82,26 @@ static uint64_t badvpn_read_le64 (const char *c_ptr) static uint8_t badvpn_read_be8 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint8_t)ptr[0] << 0); } static uint16_t badvpn_read_be16 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint16_t)ptr[0] << 8) | ((uint16_t)ptr[1] << 0); } static uint32_t badvpn_read_be32 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint32_t)ptr[0] << 24) | ((uint32_t)ptr[1] << 16) | ((uint32_t)ptr[2] << 8) | ((uint32_t)ptr[3] << 0); } static uint64_t badvpn_read_be64 (const char *c_ptr) { - const uint8_t *ptr = (void *)c_ptr; + const uint8_t *ptr = (const uint8_t *)c_ptr; return ((uint64_t)ptr[0] << 56) | ((uint64_t)ptr[1] << 48) | ((uint64_t)ptr[2] << 40) | ((uint64_t)ptr[3] << 32) | ((uint64_t)ptr[4] << 24) | ((uint64_t)ptr[5] << 16) | @@ -110,20 +110,20 @@ static uint64_t badvpn_read_be64 (const char *c_ptr) static void badvpn_write_le8 (uint8_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[0] = x >> 0; } static void badvpn_write_le16 (uint16_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[1] = x >> 8; ptr[0] = x >> 0; } static void badvpn_write_le32 (uint32_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[3] = x >> 24; ptr[2] = x >> 16; ptr[1] = x >> 8; @@ -132,7 +132,7 @@ static void badvpn_write_le32 (uint32_t x, char *c_ptr) static void badvpn_write_le64 (uint64_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[7] = x >> 56; ptr[6] = x >> 48; ptr[5] = x >> 40; @@ -145,20 +145,20 @@ static void badvpn_write_le64 (uint64_t x, char *c_ptr) static void badvpn_write_be8 (uint8_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[0] = x >> 0; } static void badvpn_write_be16 (uint16_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[0] = x >> 8; ptr[1] = x >> 0; } static void badvpn_write_be32 (uint32_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[0] = x >> 24; ptr[1] = x >> 16; ptr[2] = x >> 8; @@ -167,7 +167,7 @@ static void badvpn_write_be32 (uint32_t x, char *c_ptr) static void badvpn_write_be64 (uint64_t x, char *c_ptr) { - uint8_t *ptr = (void *)c_ptr; + uint8_t *ptr = (uint8_t *)c_ptr; ptr[0] = x >> 56; ptr[1] = x >> 48; ptr[2] = x >> 40; |