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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/openmax_dl/dl/sp/src/test/aligned_ptr.c
diff --git a/third_party/openmax_dl/dl/sp/src/test/aligned_ptr.c b/third_party/openmax_dl/dl/sp/src/test/aligned_ptr.c
new file mode 100644
index 0000000000000000000000000000000000000000..d80167cf30978a2cd596ca4e62d8f7c8b8e80361
--- /dev/null
+++ b/third_party/openmax_dl/dl/sp/src/test/aligned_ptr.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "dl/sp/src/test/aligned_ptr.h"
+
+#include <stdlib.h>
+
+/* |alignment| is the byte alignment and MUST be a power of two. */
+struct AlignedPtr* AllocAlignedPointer(int alignment, int bytes) {
+ struct AlignedPtr* aligned_ptr;
+ unsigned long raw_address;
+
+ aligned_ptr = (struct AlignedPtr*) malloc(sizeof(*aligned_ptr));
+ aligned_ptr->raw_pointer_ = malloc(bytes + alignment);
+ raw_address = (unsigned long) aligned_ptr->raw_pointer_;
+ raw_address = (raw_address + alignment - 1) & ~(alignment - 1);
+ aligned_ptr->aligned_pointer_ = (void*) raw_address;
+
+ return aligned_ptr;
+}
+
+void FreeAlignedPointer(struct AlignedPtr* pointer) {
+ free(pointer->raw_pointer_);
+ free(pointer);
+}

Powered by Google App Engine
This is Rietveld 408576698