Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: third_party/openmax_dl/dl/sp/src/test/aligned_ptr.c

Issue 12317152: Add openmax dl routines for review. MUST NOT BE LANDED (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "dl/sp/src/test/aligned_ptr.h"
12
13 #include <stdlib.h>
14
15 /* |alignment| is the byte alignment and MUST be a power of two. */
16 struct AlignedPtr* AllocAlignedPointer(int alignment, int bytes) {
17 struct AlignedPtr* aligned_ptr;
18 unsigned long raw_address;
19
20 aligned_ptr = (struct AlignedPtr*) malloc(sizeof(*aligned_ptr));
21 aligned_ptr->raw_pointer_ = malloc(bytes + alignment);
22 raw_address = (unsigned long) aligned_ptr->raw_pointer_;
23 raw_address = (raw_address + alignment - 1) & ~(alignment - 1);
24 aligned_ptr->aligned_pointer_ = (void*) raw_address;
25
26 return aligned_ptr;
27 }
28
29 void FreeAlignedPointer(struct AlignedPtr* pointer) {
30 free(pointer->raw_pointer_);
31 free(pointer);
32 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698