Loading applypatch/imgdiff.cpp +16 −16 Original line number Diff line number Diff line Loading @@ -189,7 +189,7 @@ unsigned char* ReadZip(const char* filename, } size_t sz = static_cast<size_t>(st.st_size); unsigned char* img = reinterpret_cast<unsigned char*>(malloc(sz)); unsigned char* img = static_cast<unsigned char*>(malloc(sz)); FILE* f = fopen(filename, "rb"); if (fread(img, 1, sz, f) != sz) { printf("failed to read \"%s\" %s\n", filename, strerror(errno)); Loading @@ -216,7 +216,7 @@ unsigned char* ReadZip(const char* filename, int cdcount = Read2(img+i+8); int cdoffset = Read4(img+i+16); ZipFileEntry* temp_entries = reinterpret_cast<ZipFileEntry*>(malloc( ZipFileEntry* temp_entries = static_cast<ZipFileEntry*>(malloc( cdcount * sizeof(ZipFileEntry))); int entrycount = 0; Loading @@ -234,7 +234,7 @@ unsigned char* ReadZip(const char* filename, int mlen = Read2(cd+32); // file comment len int hoffset = Read4(cd+42); // local header offset char* filename = reinterpret_cast<char*>(malloc(nlen+1)); char* filename = static_cast<char*>(malloc(nlen+1)); memcpy(filename, cd+46, nlen); filename[nlen] = '\0'; Loading Loading @@ -283,7 +283,7 @@ unsigned char* ReadZip(const char* filename, #endif *num_chunks = 0; *chunks = reinterpret_cast<ImageChunk*>(malloc((entrycount*2+2) * sizeof(ImageChunk))); *chunks = static_cast<ImageChunk*>(malloc((entrycount*2+2) * sizeof(ImageChunk))); ImageChunk* curr = *chunks; if (include_pseudo_chunk) { Loading @@ -308,7 +308,7 @@ unsigned char* ReadZip(const char* filename, curr->filename = temp_entries[nextentry].filename; curr->len = temp_entries[nextentry].uncomp_len; curr->data = reinterpret_cast<unsigned char*>(malloc(curr->len)); curr->data = static_cast<unsigned char*>(malloc(curr->len)); z_stream strm; strm.zalloc = Z_NULL; Loading Loading @@ -378,7 +378,7 @@ unsigned char* ReadImage(const char* filename, } size_t sz = static_cast<size_t>(st.st_size); unsigned char* img = reinterpret_cast<unsigned char*>(malloc(sz + 4)); unsigned char* img = static_cast<unsigned char*>(malloc(sz + 4)); FILE* f = fopen(filename, "rb"); if (fread(img, 1, sz, f) != sz) { printf("failed to read \"%s\" %s\n", filename, strerror(errno)); Loading Loading @@ -408,7 +408,7 @@ unsigned char* ReadImage(const char* filename, size_t chunk_offset = pos; *num_chunks += 3; *chunks = reinterpret_cast<ImageChunk*>(realloc(*chunks, *chunks = static_cast<ImageChunk*>(realloc(*chunks, *num_chunks * sizeof(ImageChunk))); ImageChunk* curr = *chunks + (*num_chunks-3); Loading @@ -431,7 +431,7 @@ unsigned char* ReadImage(const char* filename, size_t allocated = 32768; curr->len = 0; curr->data = reinterpret_cast<unsigned char*>(malloc(allocated)); curr->data = static_cast<unsigned char*>(malloc(allocated)); curr->start = pos; curr->deflate_data = p; Loading Loading @@ -459,7 +459,7 @@ unsigned char* ReadImage(const char* filename, curr->len = allocated - strm.avail_out; if (strm.avail_out == 0) { allocated *= 2; curr->data = reinterpret_cast<unsigned char*>(realloc(curr->data, allocated)); curr->data = static_cast<unsigned char*>(realloc(curr->data, allocated)); } } while (ret != Z_STREAM_END); Loading Loading @@ -502,7 +502,7 @@ unsigned char* ReadImage(const char* filename, // Reallocate the list for every chunk; we expect the number of // chunks to be small (5 for typical boot and recovery images). ++*num_chunks; *chunks = reinterpret_cast<ImageChunk*>(realloc(*chunks, *num_chunks * sizeof(ImageChunk))); *chunks = static_cast<ImageChunk*>(realloc(*chunks, *num_chunks * sizeof(ImageChunk))); ImageChunk* curr = *chunks + (*num_chunks-1); curr->start = pos; Loading Loading @@ -585,7 +585,7 @@ int ReconstructDeflateChunk(ImageChunk* chunk) { return -1; } unsigned char* out = reinterpret_cast<unsigned char*>(malloc(BUFFER_SIZE)); unsigned char* out = static_cast<unsigned char*>(malloc(BUFFER_SIZE)); // We only check two combinations of encoder parameters: level 6 // (the default) and level 9 (the maximum). Loading Loading @@ -646,7 +646,7 @@ unsigned char* MakePatch(ImageChunk* src, ImageChunk* tgt, size_t* size) { size_t sz = static_cast<size_t>(st.st_size); // TODO: Memory leak on error return. unsigned char* data = reinterpret_cast<unsigned char*>(malloc(sz)); unsigned char* data = static_cast<unsigned char*>(malloc(sz)); if (tgt->type == CHUNK_NORMAL && tgt->len <= sz) { unlink(ptemp); Loading Loading @@ -813,7 +813,7 @@ int main(int argc, char** argv) { return 1; } bonus_size = st.st_size; bonus_data = reinterpret_cast<unsigned char*>(malloc(bonus_size)); bonus_data = static_cast<unsigned char*>(malloc(bonus_size)); FILE* f = fopen(argv[2], "rb"); if (f == NULL) { printf("failed to open bonus file %s: %s\n", argv[2], strerror(errno)); Loading Loading @@ -959,9 +959,9 @@ int main(int argc, char** argv) { DumpChunks(src_chunks, num_src_chunks); printf("Construct patches for %d chunks...\n", num_tgt_chunks); unsigned char** patch_data = reinterpret_cast<unsigned char**>(malloc( unsigned char** patch_data = static_cast<unsigned char**>(malloc( num_tgt_chunks * sizeof(unsigned char*))); size_t* patch_size = reinterpret_cast<size_t*>(malloc(num_tgt_chunks * sizeof(size_t))); size_t* patch_size = static_cast<size_t*>(malloc(num_tgt_chunks * sizeof(size_t))); for (i = 0; i < num_tgt_chunks; ++i) { if (zip_mode) { ImageChunk* src; Loading @@ -975,7 +975,7 @@ int main(int argc, char** argv) { } else { if (i == 1 && bonus_data) { printf(" using %zu bytes of bonus data for chunk %d\n", bonus_size, i); src_chunks[i].data = reinterpret_cast<unsigned char*>(realloc(src_chunks[i].data, src_chunks[i].data = static_cast<unsigned char*>(realloc(src_chunks[i].data, src_chunks[i].len + bonus_size)); memcpy(src_chunks[i].data+src_chunks[i].len, bonus_data, bonus_size); src_chunks[i].len += bonus_size; Loading minadbd/minadbd_services.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie) { return -1; } stinfo* sti = reinterpret_cast<stinfo*>(malloc(sizeof(stinfo))); stinfo* sti = static_cast<stinfo*>(malloc(sizeof(stinfo))); if(sti == 0) fatal("cannot allocate stinfo"); sti->func = func; sti->cookie = cookie; Loading minui/graphics.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -298,14 +298,14 @@ static void gr_init_font(void) // fall back to the compiled-in font. gr_font = reinterpret_cast<GRFont*>(calloc(1, sizeof(*gr_font))); gr_font->texture = reinterpret_cast<GRSurface*>(malloc(sizeof(*gr_font->texture))); gr_font = static_cast<GRFont*>(calloc(sizeof(*gr_font), 1)); gr_font->texture = static_cast<GRSurface*>(malloc(sizeof(*gr_font->texture))); gr_font->texture->width = font.width; gr_font->texture->height = font.height; gr_font->texture->row_bytes = font.width; gr_font->texture->pixel_bytes = 1; unsigned char* bits = reinterpret_cast<unsigned char*>(malloc(font.width * font.height)); unsigned char* bits = static_cast<unsigned char*>(malloc(font.width * font.height)); gr_font->texture->data = reinterpret_cast<unsigned char*>(bits); unsigned char data; Loading minui/graphics_adf.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ static int adf_surface_init(adf_pdata *pdata, drm_mode_modeinfo *mode, adf_surfa surf->base.row_bytes = surf->pitch; surf->base.pixel_bytes = (pdata->format == DRM_FORMAT_RGB565) ? 2 : 4; surf->base.data = reinterpret_cast<uint8_t*>(mmap(NULL, surf->base.data = static_cast<uint8_t*>(mmap(NULL, surf->pitch * surf->base.height, PROT_WRITE, MAP_SHARED, surf->fd, surf->offset)); if (surf->base.data == MAP_FAILED) { Loading Loading @@ -259,7 +259,7 @@ static void adf_exit(minui_backend *backend) minui_backend *open_adf() { adf_pdata* pdata = reinterpret_cast<adf_pdata*>(calloc(1, sizeof(*pdata))); adf_pdata* pdata = static_cast<adf_pdata*>(calloc(1, sizeof(*pdata))); if (!pdata) { perror("allocating adf backend failed"); return NULL; Loading minui/graphics_fbdev.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ static GRSurface* fbdev_init(minui_backend* backend) { gr_framebuffer[0].height = vi.yres; gr_framebuffer[0].row_bytes = fi.line_length; gr_framebuffer[0].pixel_bytes = vi.bits_per_pixel / 8; gr_framebuffer[0].data = reinterpret_cast<uint8_t*>(bits); gr_framebuffer[0].data = static_cast<uint8_t*>(bits); memset(gr_framebuffer[0].data, 0, gr_framebuffer[0].height * gr_framebuffer[0].row_bytes); /* check if we can use double buffering */ Loading Loading
applypatch/imgdiff.cpp +16 −16 Original line number Diff line number Diff line Loading @@ -189,7 +189,7 @@ unsigned char* ReadZip(const char* filename, } size_t sz = static_cast<size_t>(st.st_size); unsigned char* img = reinterpret_cast<unsigned char*>(malloc(sz)); unsigned char* img = static_cast<unsigned char*>(malloc(sz)); FILE* f = fopen(filename, "rb"); if (fread(img, 1, sz, f) != sz) { printf("failed to read \"%s\" %s\n", filename, strerror(errno)); Loading @@ -216,7 +216,7 @@ unsigned char* ReadZip(const char* filename, int cdcount = Read2(img+i+8); int cdoffset = Read4(img+i+16); ZipFileEntry* temp_entries = reinterpret_cast<ZipFileEntry*>(malloc( ZipFileEntry* temp_entries = static_cast<ZipFileEntry*>(malloc( cdcount * sizeof(ZipFileEntry))); int entrycount = 0; Loading @@ -234,7 +234,7 @@ unsigned char* ReadZip(const char* filename, int mlen = Read2(cd+32); // file comment len int hoffset = Read4(cd+42); // local header offset char* filename = reinterpret_cast<char*>(malloc(nlen+1)); char* filename = static_cast<char*>(malloc(nlen+1)); memcpy(filename, cd+46, nlen); filename[nlen] = '\0'; Loading Loading @@ -283,7 +283,7 @@ unsigned char* ReadZip(const char* filename, #endif *num_chunks = 0; *chunks = reinterpret_cast<ImageChunk*>(malloc((entrycount*2+2) * sizeof(ImageChunk))); *chunks = static_cast<ImageChunk*>(malloc((entrycount*2+2) * sizeof(ImageChunk))); ImageChunk* curr = *chunks; if (include_pseudo_chunk) { Loading @@ -308,7 +308,7 @@ unsigned char* ReadZip(const char* filename, curr->filename = temp_entries[nextentry].filename; curr->len = temp_entries[nextentry].uncomp_len; curr->data = reinterpret_cast<unsigned char*>(malloc(curr->len)); curr->data = static_cast<unsigned char*>(malloc(curr->len)); z_stream strm; strm.zalloc = Z_NULL; Loading Loading @@ -378,7 +378,7 @@ unsigned char* ReadImage(const char* filename, } size_t sz = static_cast<size_t>(st.st_size); unsigned char* img = reinterpret_cast<unsigned char*>(malloc(sz + 4)); unsigned char* img = static_cast<unsigned char*>(malloc(sz + 4)); FILE* f = fopen(filename, "rb"); if (fread(img, 1, sz, f) != sz) { printf("failed to read \"%s\" %s\n", filename, strerror(errno)); Loading Loading @@ -408,7 +408,7 @@ unsigned char* ReadImage(const char* filename, size_t chunk_offset = pos; *num_chunks += 3; *chunks = reinterpret_cast<ImageChunk*>(realloc(*chunks, *chunks = static_cast<ImageChunk*>(realloc(*chunks, *num_chunks * sizeof(ImageChunk))); ImageChunk* curr = *chunks + (*num_chunks-3); Loading @@ -431,7 +431,7 @@ unsigned char* ReadImage(const char* filename, size_t allocated = 32768; curr->len = 0; curr->data = reinterpret_cast<unsigned char*>(malloc(allocated)); curr->data = static_cast<unsigned char*>(malloc(allocated)); curr->start = pos; curr->deflate_data = p; Loading Loading @@ -459,7 +459,7 @@ unsigned char* ReadImage(const char* filename, curr->len = allocated - strm.avail_out; if (strm.avail_out == 0) { allocated *= 2; curr->data = reinterpret_cast<unsigned char*>(realloc(curr->data, allocated)); curr->data = static_cast<unsigned char*>(realloc(curr->data, allocated)); } } while (ret != Z_STREAM_END); Loading Loading @@ -502,7 +502,7 @@ unsigned char* ReadImage(const char* filename, // Reallocate the list for every chunk; we expect the number of // chunks to be small (5 for typical boot and recovery images). ++*num_chunks; *chunks = reinterpret_cast<ImageChunk*>(realloc(*chunks, *num_chunks * sizeof(ImageChunk))); *chunks = static_cast<ImageChunk*>(realloc(*chunks, *num_chunks * sizeof(ImageChunk))); ImageChunk* curr = *chunks + (*num_chunks-1); curr->start = pos; Loading Loading @@ -585,7 +585,7 @@ int ReconstructDeflateChunk(ImageChunk* chunk) { return -1; } unsigned char* out = reinterpret_cast<unsigned char*>(malloc(BUFFER_SIZE)); unsigned char* out = static_cast<unsigned char*>(malloc(BUFFER_SIZE)); // We only check two combinations of encoder parameters: level 6 // (the default) and level 9 (the maximum). Loading Loading @@ -646,7 +646,7 @@ unsigned char* MakePatch(ImageChunk* src, ImageChunk* tgt, size_t* size) { size_t sz = static_cast<size_t>(st.st_size); // TODO: Memory leak on error return. unsigned char* data = reinterpret_cast<unsigned char*>(malloc(sz)); unsigned char* data = static_cast<unsigned char*>(malloc(sz)); if (tgt->type == CHUNK_NORMAL && tgt->len <= sz) { unlink(ptemp); Loading Loading @@ -813,7 +813,7 @@ int main(int argc, char** argv) { return 1; } bonus_size = st.st_size; bonus_data = reinterpret_cast<unsigned char*>(malloc(bonus_size)); bonus_data = static_cast<unsigned char*>(malloc(bonus_size)); FILE* f = fopen(argv[2], "rb"); if (f == NULL) { printf("failed to open bonus file %s: %s\n", argv[2], strerror(errno)); Loading Loading @@ -959,9 +959,9 @@ int main(int argc, char** argv) { DumpChunks(src_chunks, num_src_chunks); printf("Construct patches for %d chunks...\n", num_tgt_chunks); unsigned char** patch_data = reinterpret_cast<unsigned char**>(malloc( unsigned char** patch_data = static_cast<unsigned char**>(malloc( num_tgt_chunks * sizeof(unsigned char*))); size_t* patch_size = reinterpret_cast<size_t*>(malloc(num_tgt_chunks * sizeof(size_t))); size_t* patch_size = static_cast<size_t*>(malloc(num_tgt_chunks * sizeof(size_t))); for (i = 0; i < num_tgt_chunks; ++i) { if (zip_mode) { ImageChunk* src; Loading @@ -975,7 +975,7 @@ int main(int argc, char** argv) { } else { if (i == 1 && bonus_data) { printf(" using %zu bytes of bonus data for chunk %d\n", bonus_size, i); src_chunks[i].data = reinterpret_cast<unsigned char*>(realloc(src_chunks[i].data, src_chunks[i].data = static_cast<unsigned char*>(realloc(src_chunks[i].data, src_chunks[i].len + bonus_size)); memcpy(src_chunks[i].data+src_chunks[i].len, bonus_data, bonus_size); src_chunks[i].len += bonus_size; Loading
minadbd/minadbd_services.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie) { return -1; } stinfo* sti = reinterpret_cast<stinfo*>(malloc(sizeof(stinfo))); stinfo* sti = static_cast<stinfo*>(malloc(sizeof(stinfo))); if(sti == 0) fatal("cannot allocate stinfo"); sti->func = func; sti->cookie = cookie; Loading
minui/graphics.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -298,14 +298,14 @@ static void gr_init_font(void) // fall back to the compiled-in font. gr_font = reinterpret_cast<GRFont*>(calloc(1, sizeof(*gr_font))); gr_font->texture = reinterpret_cast<GRSurface*>(malloc(sizeof(*gr_font->texture))); gr_font = static_cast<GRFont*>(calloc(sizeof(*gr_font), 1)); gr_font->texture = static_cast<GRSurface*>(malloc(sizeof(*gr_font->texture))); gr_font->texture->width = font.width; gr_font->texture->height = font.height; gr_font->texture->row_bytes = font.width; gr_font->texture->pixel_bytes = 1; unsigned char* bits = reinterpret_cast<unsigned char*>(malloc(font.width * font.height)); unsigned char* bits = static_cast<unsigned char*>(malloc(font.width * font.height)); gr_font->texture->data = reinterpret_cast<unsigned char*>(bits); unsigned char data; Loading
minui/graphics_adf.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ static int adf_surface_init(adf_pdata *pdata, drm_mode_modeinfo *mode, adf_surfa surf->base.row_bytes = surf->pitch; surf->base.pixel_bytes = (pdata->format == DRM_FORMAT_RGB565) ? 2 : 4; surf->base.data = reinterpret_cast<uint8_t*>(mmap(NULL, surf->base.data = static_cast<uint8_t*>(mmap(NULL, surf->pitch * surf->base.height, PROT_WRITE, MAP_SHARED, surf->fd, surf->offset)); if (surf->base.data == MAP_FAILED) { Loading Loading @@ -259,7 +259,7 @@ static void adf_exit(minui_backend *backend) minui_backend *open_adf() { adf_pdata* pdata = reinterpret_cast<adf_pdata*>(calloc(1, sizeof(*pdata))); adf_pdata* pdata = static_cast<adf_pdata*>(calloc(1, sizeof(*pdata))); if (!pdata) { perror("allocating adf backend failed"); return NULL; Loading
minui/graphics_fbdev.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ static GRSurface* fbdev_init(minui_backend* backend) { gr_framebuffer[0].height = vi.yres; gr_framebuffer[0].row_bytes = fi.line_length; gr_framebuffer[0].pixel_bytes = vi.bits_per_pixel / 8; gr_framebuffer[0].data = reinterpret_cast<uint8_t*>(bits); gr_framebuffer[0].data = static_cast<uint8_t*>(bits); memset(gr_framebuffer[0].data, 0, gr_framebuffer[0].height * gr_framebuffer[0].row_bytes); /* check if we can use double buffering */ Loading