Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
allocation.h
Go to the documentation of this file.
1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_PLATFORM_ALLOCATION_H_
6#define RUNTIME_PLATFORM_ALLOCATION_H_
7
9#include "platform/assert.h"
10
11namespace dart {
12
13void* calloc(size_t n, size_t size);
14void* malloc(size_t size);
15void* realloc(void* ptr, size_t size);
16
17// Stack allocated objects subclass from this base class. Objects of this type
18// cannot be allocated on either the C or object heaps. Destructors for objects
19// of this type will not be run unless the stack is unwound through normal
20// program control flow.
22 public:
25
26 private:
27 DISALLOW_ALLOCATION();
29};
30
31// Static allocated classes only contain static members and can never
32// be instantiated in the heap or on the stack.
33class AllStatic {
34 private:
35 DISALLOW_ALLOCATION();
37};
38
40 public:
42
43 // Intercept operator new to produce clearer error messages when we run out
44 // of memory. Don't do this when running under ASAN so it can continue to
45 // check malloc/new/new[] are paired with free/delete/delete[] respectively.
46#if !defined(USING_ADDRESS_SANITIZER)
47 void* operator new(size_t size) { return dart::malloc(size); }
48
49 void* operator new[](size_t size) { return dart::malloc(size); }
50
51 void operator delete(void* pointer) { ::free(pointer); }
52
53 void operator delete[](void* pointer) { ::free(pointer); }
54#endif
55};
56
57} // namespace dart
58
59#endif // RUNTIME_PLATFORM_ALLOCATION_H_
void * malloc(size_t size)
Definition allocation.cc:19
void * calloc(size_t n, size_t size)
Definition allocation.cc:11
void * realloc(void *ptr, size_t size)
Definition allocation.cc:27
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition globals.h:593
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581