xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/common/simple_buffer_allocator.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef QUICHE_COMMON_SIMPLE_BUFFER_ALLOCATOR_H_
6 #define QUICHE_COMMON_SIMPLE_BUFFER_ALLOCATOR_H_
7 
8 #include "quiche/common/platform/api/quiche_export.h"
9 #include "quiche/common/quiche_buffer_allocator.h"
10 
11 namespace quiche {
12 
13 // Provides buffer allocation using operators new[] and delete[] on char arrays.
14 // Note that some of the QUICHE code relies on this being the case for deleting
15 // new[]-allocated arrays from elsewhere.
16 class QUICHE_EXPORT SimpleBufferAllocator : public QuicheBufferAllocator {
17  public:
Get()18   static SimpleBufferAllocator* Get() {
19     static SimpleBufferAllocator* singleton = new SimpleBufferAllocator();
20     return singleton;
21   }
22 
23   char* New(size_t size) override;
24   char* New(size_t size, bool flag_enable) override;
25   void Delete(char* buffer) override;
26 };
27 
28 }  // namespace quiche
29 
30 #endif  // QUICHE_COMMON_SIMPLE_BUFFER_ALLOCATOR_H_
31