1 /*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <ui/GraphicBuffer.h>
18 #include "../includes/memutils.h"
19
main()20 int main() {
21 size_t size = sizeof(int) * 6;
22 int *tempBuffer = (int *)malloc(size);
23 if (!tempBuffer) {
24 return EXIT_FAILURE;
25 }
26 memset(tempBuffer, 0x0, size);
27 tempBuffer[0] = 'GB01';
28 void const *buffer = const_cast<void const *>((void *)tempBuffer);
29 int const fds[] = {0, 0};
30 size_t count = sizeof(fds) / sizeof(int);
31 int const *fd = const_cast<int const *>(fds);
32 android::GraphicBuffer *graphicBuffer = new android::GraphicBuffer();
33 graphicBuffer->unflatten(buffer, size, fd, count);
34 free(tempBuffer);
35 return EXIT_SUCCESS;
36 }
37