Add (void*) casts to memcpy/memset invocations to appease GCC 8.

A lot of these classes are not *technically* "trivially copyable"
for one reason or another, but in all of these cases it seems
OK to me to use memcpy/memset on them. Adding a cast to void*
tells GCC that "I know what I'm doing here" and shuts up the
warning.
This commit is contained in:
Augustin Cavalier 2019-05-24 14:21:37 -04:00
parent 38b015579f
commit 1705656eac
10 changed files with 116 additions and 115 deletions

View File

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -23,9 +23,9 @@ namespace agg
{
//================================================render_scanline_aa_solid
template<class Scanline, class BaseRenderer, class ColorT>
void render_scanline_aa_solid(const Scanline& sl,
BaseRenderer& ren,
template<class Scanline, class BaseRenderer, class ColorT>
void render_scanline_aa_solid(const Scanline& sl,
BaseRenderer& ren,
const ColorT& color)
{
int y = sl.y();
@ -37,14 +37,14 @@ namespace agg
int x = span->x;
if(span->len > 0)
{
ren.blend_solid_hspan(x, y, (unsigned)span->len,
color,
ren.blend_solid_hspan(x, y, (unsigned)span->len,
color,
span->covers);
}
else
{
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
color,
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
color,
*(span->covers));
}
if(--num_spans == 0) break;
@ -53,16 +53,16 @@ namespace agg
}
//===============================================render_scanlines_aa_solid
template<class Rasterizer, class Scanline,
template<class Rasterizer, class Scanline,
class BaseRenderer, class ColorT>
void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl,
void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl,
BaseRenderer& ren, const ColorT& color)
{
if(ras.rewind_scanlines())
{
// Explicitly convert "color" to the BaseRenderer color type.
// For example, it can be called with color type "rgba", while
// "rgba8" is needed. Otherwise it will be implicitly
// "rgba8" is needed. Otherwise it will be implicitly
// converted in the loop many times.
//----------------------
typename BaseRenderer::color_type ren_color(color);
@ -72,7 +72,7 @@ namespace agg
{
//render_scanline_aa_solid(sl, ren, ren_color);
// This code is equivalent to the above call (copy/paste).
// This code is equivalent to the above call (copy/paste).
// It's just a "manual" optimization for old compilers,
// like Microsoft Visual C++ v6.0
//-------------------------------
@ -85,14 +85,14 @@ namespace agg
int x = span->x;
if(span->len > 0)
{
ren.blend_solid_hspan(x, y, (unsigned)span->len,
ren_color,
ren.blend_solid_hspan(x, y, (unsigned)span->len,
ren_color,
span->covers);
}
else
{
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
ren_color,
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
ren_color,
*(span->covers));
}
if(--num_spans == 0) break;
@ -116,7 +116,7 @@ namespace agg
{
m_ren = &ren;
}
//--------------------------------------------------------------------
void color(const color_type& c) { m_color = c; }
const color_type& color() const { return m_color; }
@ -129,7 +129,7 @@ namespace agg
{
render_scanline_aa_solid(sl, *m_ren, m_color);
}
private:
base_ren_type* m_ren;
color_type m_color;
@ -148,9 +148,9 @@ namespace agg
//======================================================render_scanline_aa
template<class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanline_aa(const Scanline& sl, BaseRenderer& ren,
template<class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanline_aa(const Scanline& sl, BaseRenderer& ren,
SpanAllocator& alloc, SpanGenerator& span_gen)
{
int y = sl.y();
@ -166,7 +166,7 @@ namespace agg
if(len < 0) len = -len;
typename BaseRenderer::color_type* colors = alloc.allocate(len);
span_gen.generate(colors, x, y, len);
ren.blend_color_hspan(x, y, len, colors,
ren.blend_color_hspan(x, y, len, colors,
(span->len < 0) ? 0 : covers, *covers);
if(--num_spans == 0) break;
@ -175,9 +175,9 @@ namespace agg
}
//=====================================================render_scanlines_aa
template<class Rasterizer, class Scanline, class BaseRenderer,
template<class Rasterizer, class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
SpanAllocator& alloc, SpanGenerator& span_gen)
{
if(ras.rewind_scanlines())
@ -192,7 +192,7 @@ namespace agg
}
//====================================================renderer_scanline_aa
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
class renderer_scanline_aa
{
public:
@ -202,22 +202,22 @@ namespace agg
//--------------------------------------------------------------------
renderer_scanline_aa() : m_ren(0), m_alloc(0), m_span_gen(0) {}
renderer_scanline_aa(base_ren_type& ren,
alloc_type& alloc,
renderer_scanline_aa(base_ren_type& ren,
alloc_type& alloc,
span_gen_type& span_gen) :
m_ren(&ren),
m_alloc(&alloc),
m_span_gen(&span_gen)
{}
void attach(base_ren_type& ren,
alloc_type& alloc,
void attach(base_ren_type& ren,
alloc_type& alloc,
span_gen_type& span_gen)
{
m_ren = &ren;
m_alloc = &alloc;
m_span_gen = &span_gen;
}
//--------------------------------------------------------------------
void prepare() { m_span_gen->prepare(); }
@ -239,21 +239,21 @@ namespace agg
//===============================================render_scanline_bin_solid
template<class Scanline, class BaseRenderer, class ColorT>
void render_scanline_bin_solid(const Scanline& sl,
BaseRenderer& ren,
template<class Scanline, class BaseRenderer, class ColorT>
void render_scanline_bin_solid(const Scanline& sl,
BaseRenderer& ren,
const ColorT& color)
{
unsigned num_spans = sl.num_spans();
typename Scanline::const_iterator span = sl.begin();
for(;;)
{
ren.blend_hline(span->x,
sl.y(),
span->x - 1 + ((span->len < 0) ?
-span->len :
span->len),
color,
ren.blend_hline(span->x,
sl.y(),
span->x - 1 + ((span->len < 0) ?
-span->len :
span->len),
color,
cover_full);
if(--num_spans == 0) break;
++span;
@ -261,16 +261,16 @@ namespace agg
}
//==============================================render_scanlines_bin_solid
template<class Rasterizer, class Scanline,
template<class Rasterizer, class Scanline,
class BaseRenderer, class ColorT>
void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl,
void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl,
BaseRenderer& ren, const ColorT& color)
{
if(ras.rewind_scanlines())
{
// Explicitly convert "color" to the BaseRenderer color type.
// For example, it can be called with color type "rgba", while
// "rgba8" is needed. Otherwise it will be implicitly
// "rgba8" is needed. Otherwise it will be implicitly
// converted in the loop many times.
//----------------------
typename BaseRenderer::color_type ren_color(color);
@ -280,7 +280,7 @@ namespace agg
{
//render_scanline_bin_solid(sl, ren, ren_color);
// This code is equivalent to the above call (copy/paste).
// This code is equivalent to the above call (copy/paste).
// It's just a "manual" optimization for old compilers,
// like Microsoft Visual C++ v6.0
//-------------------------------
@ -288,12 +288,12 @@ namespace agg
typename Scanline::const_iterator span = sl.begin();
for(;;)
{
ren.blend_hline(span->x,
sl.y(),
span->x - 1 + ((span->len < 0) ?
-span->len :
span->len),
ren_color,
ren.blend_hline(span->x,
sl.y(),
span->x - 1 + ((span->len < 0) ?
-span->len :
span->len),
ren_color,
cover_full);
if(--num_spans == 0) break;
++span;
@ -316,7 +316,7 @@ namespace agg
{
m_ren = &ren;
}
//--------------------------------------------------------------------
void color(const color_type& c) { m_color = c; }
const color_type& color() const { return m_color; }
@ -329,7 +329,7 @@ namespace agg
{
render_scanline_bin_solid(sl, *m_ren, m_color);
}
private:
base_ren_type* m_ren;
color_type m_color;
@ -343,9 +343,9 @@ namespace agg
//======================================================render_scanline_bin
template<class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanline_bin(const Scanline& sl, BaseRenderer& ren,
template<class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanline_bin(const Scanline& sl, BaseRenderer& ren,
SpanAllocator& alloc, SpanGenerator& span_gen)
{
int y = sl.y();
@ -359,16 +359,16 @@ namespace agg
if(len < 0) len = -len;
typename BaseRenderer::color_type* colors = alloc.allocate(len);
span_gen.generate(colors, x, y, len);
ren.blend_color_hspan(x, y, len, colors, 0, cover_full);
ren.blend_color_hspan(x, y, len, colors, 0, cover_full);
if(--num_spans == 0) break;
++span;
}
}
//=====================================================render_scanlines_bin
template<class Rasterizer, class Scanline, class BaseRenderer,
template<class Rasterizer, class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
SpanAllocator& alloc, SpanGenerator& span_gen)
{
if(ras.rewind_scanlines())
@ -383,7 +383,7 @@ namespace agg
}
//====================================================renderer_scanline_bin
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
class renderer_scanline_bin
{
public:
@ -393,22 +393,22 @@ namespace agg
//--------------------------------------------------------------------
renderer_scanline_bin() : m_ren(0), m_alloc(0), m_span_gen(0) {}
renderer_scanline_bin(base_ren_type& ren,
alloc_type& alloc,
renderer_scanline_bin(base_ren_type& ren,
alloc_type& alloc,
span_gen_type& span_gen) :
m_ren(&ren),
m_alloc(&alloc),
m_span_gen(&span_gen)
{}
void attach(base_ren_type& ren,
alloc_type& alloc,
void attach(base_ren_type& ren,
alloc_type& alloc,
span_gen_type& span_gen)
{
m_ren = &ren;
m_alloc = &alloc;
m_span_gen = &span_gen;
}
//--------------------------------------------------------------------
void prepare() { m_span_gen->prepare(); }
@ -449,13 +449,13 @@ namespace agg
}
//========================================================render_all_paths
template<class Rasterizer, class Scanline, class Renderer,
template<class Rasterizer, class Scanline, class Renderer,
class VertexSource, class ColorStorage, class PathId>
void render_all_paths(Rasterizer& ras,
void render_all_paths(Rasterizer& ras,
Scanline& sl,
Renderer& r,
VertexSource& vs,
const ColorStorage& as,
Renderer& r,
VertexSource& vs,
const ColorStorage& as,
const PathId& path_id,
unsigned num_paths)
{
@ -477,13 +477,13 @@ namespace agg
//=============================================render_scanlines_compound
template<class Rasterizer,
class ScanlineAA,
class ScanlineBin,
class BaseRenderer,
template<class Rasterizer,
class ScanlineAA,
class ScanlineBin,
class BaseRenderer,
class SpanAllocator,
class StyleHandler>
void render_scanlines_compound(Rasterizer& ras,
void render_scanlines_compound(Rasterizer& ras,
ScanlineAA& sl_aa,
ScanlineBin& sl_bin,
BaseRenderer& ren,
@ -530,14 +530,14 @@ namespace agg
for(;;)
{
len = span_aa->len;
sh.generate_span(color_span,
span_aa->x,
sl_aa.y(),
len,
sh.generate_span(color_span,
span_aa->x,
sl_aa.y(),
len,
style);
ren.blend_color_hspan(span_aa->x,
sl_aa.y(),
ren.blend_color_hspan(span_aa->x,
sl_aa.y(),
span_aa->len,
color_span,
span_aa->covers);
@ -554,12 +554,12 @@ namespace agg
if(sl_len)
{
memset(mix_buffer + sl_start - min_x,
0,
memset((void*)(mix_buffer + sl_start - min_x),
0,
sl_len * sizeof(color_type));
memset(cover_buffer + sl_start - min_x,
0,
memset(cover_buffer + sl_start - min_x,
0,
sl_len * sizeof(cover_type));
int sl_y = 0x7FFFFFFF;
@ -620,10 +620,10 @@ namespace agg
len = span_aa->len;
colors = mix_buffer + span_aa->x - min_x;
cspan = color_span;
sh.generate_span(cspan,
span_aa->x,
sl_aa.y(),
len,
sh.generate_span(cspan,
span_aa->x,
sl_aa.y(),
len,
style);
src_covers = span_aa->covers;
dst_covers = cover_buffer + span_aa->x - min_x;
@ -651,8 +651,8 @@ namespace agg
}
}
}
ren.blend_color_hspan(sl_start,
sl_y,
ren.blend_color_hspan(sl_start,
sl_y,
sl_len,
mix_buffer + sl_start - min_x,
0,

View File

@ -72,7 +72,7 @@ struct ValuePieceLocation {
bool Copy(const ValuePieceLocation& other)
{
memcpy(this, &other, sizeof(ValuePieceLocation));
memcpy((void*)this, (void*)&other, sizeof(ValuePieceLocation));
if (type == VALUE_PIECE_LOCATION_IMPLICIT) {
void* tempValue = malloc(size);
if (tempValue == NULL) {

View File

@ -27,8 +27,8 @@ virtual ~_BTextViewSupportBuffer_();
int32 ItemCount() const;
protected:
int32 fExtraCount;
int32 fItemCount;
int32 fExtraCount;
int32 fItemCount;
int32 fBufferCount;
T* fBuffer;
};
@ -61,7 +61,7 @@ _BTextViewSupportBuffer_<T>::InsertItemsAt(int32 inNumItems,
{
if (inNumItems < 1)
return;
inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex;
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
@ -69,15 +69,16 @@ _BTextViewSupportBuffer_<T>::InsertItemsAt(int32 inNumItems,
int32 logSize = fItemCount * sizeof(T);
if ((logSize + delta) >= fBufferCount) {
fBufferCount = logSize + delta + (fExtraCount * sizeof(T));
fBuffer = (T*)realloc(fBuffer, fBufferCount);
fBuffer = (T*)realloc((void*)fBuffer, fBufferCount);
if (fBuffer == NULL)
debugger("InsertItemsAt(): reallocation failed");
}
T* loc = fBuffer + inAtIndex;
memmove(loc + inNumItems, loc, (fItemCount - inAtIndex) * sizeof(T));
memcpy(loc, inItem, delta);
memmove((void*)(loc + inNumItems), (void*)loc,
(fItemCount - inAtIndex) * sizeof(T));
memcpy((void*)loc, (void*)inItem, delta);
fItemCount += inNumItems;
}
@ -89,14 +90,14 @@ _BTextViewSupportBuffer_<T>::RemoveItemsAt(int32 inNumItems,
{
if (inNumItems < 1)
return;
inAtIndex = (inAtIndex > fItemCount - 1) ? (fItemCount - 1) : inAtIndex;
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
T* loc = fBuffer + inAtIndex;
memmove(loc, loc + inNumItems,
memmove(loc, loc + inNumItems,
(fItemCount - (inNumItems + inAtIndex)) * sizeof(T));
int32 delta = inNumItems * sizeof(T);
int32 logSize = fItemCount * sizeof(T);
uint32 extraSize = fBufferCount - (logSize - delta);
@ -106,7 +107,7 @@ _BTextViewSupportBuffer_<T>::RemoveItemsAt(int32 inNumItems,
if (fBuffer == NULL)
debugger("RemoveItemsAt(): reallocation failed");
}
fItemCount -= inNumItems;
}

View File

@ -198,11 +198,11 @@ SavePalette::SavePalette(int mode)
{
if (IsValid()) {
if (fMode == WEB_SAFE_PALETTE) {
memcpy(pal, wsp, sizeof(rgb_color) * 256);
memcpy((void*)pal, wsp, sizeof(rgb_color) * 256);
fSize = 216;
} else if (fMode == BEOS_SYSTEM_PALETTE) {
color_map* map = (color_map*)system_colors();
memcpy(pal, map->color_list, sizeof(rgb_color) * 256);
memcpy((void*)pal, map->color_list, sizeof(rgb_color) * 256);
fSize = 256;
} else if (fMode == GREYSCALE_PALETTE) {
for (int i = 0; i < 256; i++) {
@ -405,7 +405,7 @@ SavePalette::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha)
}
} else {
int closestDistance = 255 * 255 * 3;
if (fTransparentMode == AUTO_TRANSPARENCY) {
for (int i = 0; i < fTransparentIndex && closestDistance != 0;
i++) {

View File

@ -57,7 +57,7 @@ TransformPointsBox::TransformPointsBox(CanvasView* view,
fPoints[i].point_out.x, fPoints[i].point_out.y);
bounds = bounds | dummy;
} else {
memset(&fPoints[i], 0, sizeof(control_point));
memset((void*)&fPoints[i], 0, sizeof(control_point));
}
}
}

View File

@ -353,7 +353,7 @@ BVariant::_SetTo(const BVariant& other)
other.fReferenceable->AcquireReference();
}
memcpy(this, &other, sizeof(BVariant));
memcpy((void*)this, (void*)&other, sizeof(BVariant));
}

View File

@ -474,7 +474,7 @@ OpenHashElementArray<Element>::Add()
memcpy(newData, fData, fSize * sizeof(Element));
free(fData);
*/
Element *newData = (Element*)realloc(fData,
Element *newData = (Element*)realloc((void*)fData,
(size_t)newSize * sizeof(Element));
if (!newData)
return NULL;

View File

@ -788,7 +788,7 @@ BPoseView::SavePoseLocations(BRect* frameIfDesktop)
extendedPoseInfo = (ExtendedPoseInfo*)
new char [size];
memset(extendedPoseInfo, 0, size);
memset((void*)extendedPoseInfo, 0, size);
extendedPoseInfo->fWorkspaces = 0xffffffff;
extendedPoseInfo->fInvisible = false;
extendedPoseInfo->fShowFromBootOnly = false;

View File

@ -145,7 +145,7 @@ VectorPath::VectorPath(BMessage* archive)
if (archive->GetInfo("point", &typeFound, &countFound) >= B_OK
&& typeFound == B_POINT_TYPE
&& _SetPointCount(countFound)) {
memset(fPath, 0, fAllocCount * sizeof(control_point));
memset((void*)fPath, 0, fAllocCount * sizeof(control_point));
BPoint point;
BPoint pointIn;
@ -322,7 +322,7 @@ VectorPath::operator==(const VectorPath& other) const
{
if (fClosed != other.fClosed)
return false;
if (fPointCount != other.fPointCount)
return false;
@ -1073,7 +1073,7 @@ VectorPath::_SetPointCount(int32 count)
fPath = obj_new(control_point, fAllocCount);
if (fPath != NULL) {
memset(fPath + fPointCount, 0,
memset((void*)(fPath + fPointCount), 0,
(fAllocCount - fPointCount) * sizeof(control_point));
}
}

View File

@ -842,7 +842,7 @@ KeyboardLayout::_InitFrom(const char* data)
state.mode = kKeyShape;
break;
case kKeyShape:
memset(&key, 0, sizeof(Key));
memset((void*)&key, 0, sizeof(Key));
if (!_GetShape(state, term.String(), key))
return B_BAD_VALUE;