uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, const VectorOfAny *vec, uoffset_t num_elems, uoffset_t elem_size, std::vector<uint8_t> *flatbuf, const reflection::Object *root_table) { auto delta_elem = static_cast<int>(newsize) - static_cast<int>(num_elems); auto delta_bytes = delta_elem * static_cast<int>(elem_size); auto vec_start = reinterpret_cast<const uint8_t *>(vec) - flatbuf->data(); auto start = static_cast<uoffset_t>(vec_start + sizeof(uoffset_t) + elem_size * num_elems); if (delta_bytes) { if (delta_elem < 0) { // Clear elements we're throwing away, since some might remain in the // buffer. auto size_clear = -delta_elem * elem_size; memset(flatbuf->data() + start - size_clear, 0, size_clear); } ResizeContext(schema, start, delta_bytes, flatbuf, root_table); WriteScalar(flatbuf->data() + vec_start, newsize); // Length field. // Set new elements to 0.. this can be overwritten by the caller. if (delta_elem > 0) { memset(flatbuf->data() + start, 0, delta_elem * elem_size); } } return flatbuf->data() + start; }
bool G2DTestSystemDriver::HandleEvent (iEvent &Event) { if (myG2D && (Event.Name == SystemOpen)) { white = MakeColor (255, 255, 255); yellow = MakeColor (255, 255, 0); green = MakeColor (0, 255, 0); red = MakeColor (255, 0, 0); blue = MakeColor (0, 0, 255); gray = MakeColor (128, 128, 128); dsteel = MakeColor (80, 100, 112); black = MakeColor (0, 0, 0); } else if (myG2D && (Event.Name == CanvasResize)) { ResizeContext (); } else if (Event.Name == KeyboardDown) { if (state_sptr) switch (state [state_sptr - 1]) { case stWaitKey: lastkey = csKeyEventHelper::GetCookedCode (&Event); break; case stTestLinePerf: lastkey2 = csKeyEventHelper::GetCookedCode (&Event); break; case stTestTextDraw: lastkey3 = csKeyEventHelper::GetCookedCode (&Event); break; case stTestTextDraw2: lastkey4 = csKeyEventHelper::GetCookedCode (&Event); break; case stPixelClipTest: lastkey5 = csKeyEventHelper::GetCookedCode (&Event); break; case stLineClipTest: lastkey6 = csKeyEventHelper::GetCookedCode (&Event); break; case stBoxClipTest: lastkey7 = csKeyEventHelper::GetCookedCode (&Event); break; case stFontClipTest: lastkey8 = csKeyEventHelper::GetCookedCode (&Event); break; case stCustomCursor: lastkey9 = csKeyEventHelper::GetCookedCode (&Event); break; default: break; } } return false; }