/* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include "../includes/memutils.h" int main() { size_t size = sizeof(int) * 6; int *tempBuffer = (int *)malloc(size); if (!tempBuffer) { return EXIT_FAILURE; } memset(tempBuffer, 0x0, size); tempBuffer[0] = 'GB01'; void const *buffer = const_cast((void *)tempBuffer); int const fds[] = {0, 0}; size_t count = sizeof(fds) / sizeof(int); int const *fd = const_cast(fds); android::GraphicBuffer *graphicBuffer = new android::GraphicBuffer(); graphicBuffer->unflatten(buffer, size, fd, count); free(tempBuffer); return EXIT_SUCCESS; }