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

Unified Diff: third_party/grpc/src/core/support/alloc.c

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « third_party/grpc/src/core/statistics/window_stats.c ('k') | third_party/grpc/src/core/support/avl.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/grpc/src/core/support/alloc.c
diff --git a/third_party/WebKit/Source/core/svg/SVGUnknownElement.h b/third_party/grpc/src/core/support/alloc.c
similarity index 51%
copy from third_party/WebKit/Source/core/svg/SVGUnknownElement.h
copy to third_party/grpc/src/core/support/alloc.c
index 45ff8961916901817bc5dbe55c519f6cdbfe53af..0a064b2c188b37c18606df2400602905572c7cd2 100644
--- a/third_party/WebKit/Source/core/svg/SVGUnknownElement.h
+++ b/third_party/grpc/src/core/support/alloc.c
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,31 +28,63 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
*/
-#ifndef SVGUnknownElement_h
-#define SVGUnknownElement_h
+#include <grpc/support/alloc.h>
+
+#include <stdlib.h>
+#include <grpc/support/log.h>
+#include <grpc/support/port_platform.h>
+#include "src/core/profiling/timers.h"
+
+static gpr_allocation_functions g_alloc_functions = {malloc, realloc, free};
-#include "core/svg/SVGElement.h"
+gpr_allocation_functions gpr_get_allocation_functions() {
+ return g_alloc_functions;
+}
-namespace blink {
+void gpr_set_allocation_functions(gpr_allocation_functions functions) {
+ GPR_ASSERT(functions.malloc_fn != NULL);
+ GPR_ASSERT(functions.realloc_fn != NULL);
+ GPR_ASSERT(functions.free_fn != NULL);
+ g_alloc_functions = functions;
+}
-// This type is used for 2 kinds of elements:
-// - Unknown Elements in SVG namespace
-// - Registered custom tag elements in SVG namespace (http://www.w3.org/TR/2013/WD-custom-elements-20130514/#registering-custom-elements)
-//
-// The main purpose of this class at the moment is to override layoutObjectIsNeeded() to return
-// false to make sure we don't attempt to layout such elements.
-class SVGUnknownElement final : public SVGElement {
-public:
- DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(SVGUnknownElement);
+void *gpr_malloc(size_t size) {
+ void *p;
+ GPR_TIMER_BEGIN("gpr_malloc", 0);
+ p = g_alloc_functions.malloc_fn(size);
+ if (!p) {
+ abort();
+ }
+ GPR_TIMER_END("gpr_malloc", 0);
+ return p;
+}
-private:
- SVGUnknownElement(const QualifiedName&, Document&);
+void gpr_free(void *p) {
+ GPR_TIMER_BEGIN("gpr_free", 0);
+ g_alloc_functions.free_fn(p);
+ GPR_TIMER_END("gpr_free", 0);
+}
- bool layoutObjectIsNeeded(const ComputedStyle&) override { return false; }
-};
+void *gpr_realloc(void *p, size_t size) {
+ GPR_TIMER_BEGIN("gpr_realloc", 0);
+ p = g_alloc_functions.realloc_fn(p, size);
+ if (!p) {
+ abort();
+ }
+ GPR_TIMER_END("gpr_realloc", 0);
+ return p;
+}
-} // namespace blink
+void *gpr_malloc_aligned(size_t size, size_t alignment_log) {
+ size_t alignment = ((size_t)1) << alignment_log;
+ size_t extra = alignment - 1 + sizeof(void *);
+ void *p = gpr_malloc(size + extra);
+ void **ret = (void **)(((uintptr_t)p + extra) & ~(alignment - 1));
+ ret[-1] = p;
+ return (void *)ret;
+}
-#endif // SVGUnknownElement_h
+void gpr_free_aligned(void *ptr) { free(((void **)ptr)[-1]); }
« no previous file with comments | « third_party/grpc/src/core/statistics/window_stats.c ('k') | third_party/grpc/src/core/support/avl.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698