| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkChunkAlloc_DEFINED | 10 #ifndef SkChunkAlloc_DEFINED |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 /** Call this to unalloc the most-recently allocated ptr by alloc(). On | 36 /** Call this to unalloc the most-recently allocated ptr by alloc(). On |
| 37 success, the number of bytes freed is returned, or 0 if the block could | 37 success, the number of bytes freed is returned, or 0 if the block could |
| 38 not be unallocated. This is a hint to the underlying allocator that | 38 not be unallocated. This is a hint to the underlying allocator that |
| 39 the previous allocation may be reused, but the implementation is free | 39 the previous allocation may be reused, but the implementation is free |
| 40 to ignore this call (and return 0). | 40 to ignore this call (and return 0). |
| 41 */ | 41 */ |
| 42 size_t unalloc(void* ptr); | 42 size_t unalloc(void* ptr); |
| 43 | 43 |
| 44 size_t totalCapacity() const { return fTotalCapacity; } | 44 size_t totalCapacity() const { return fTotalCapacity; } |
| 45 size_t totalUsed() const { return fTotalUsed; } |
| 45 int blockCount() const { return fBlockCount; } | 46 int blockCount() const { return fBlockCount; } |
| 46 | 47 |
| 47 /** | 48 /** |
| 48 * Returns true if the specified address is within one of the chunks, and | 49 * Returns true if the specified address is within one of the chunks, and |
| 49 * has at least 1-byte following the address (i.e. if addr points to the | 50 * has at least 1-byte following the address (i.e. if addr points to the |
| 50 * end of a chunk, then contains() will return false). | 51 * end of a chunk, then contains() will return false). |
| 51 */ | 52 */ |
| 52 bool contains(const void* addr) const; | 53 bool contains(const void* addr) const; |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 struct Block; | 56 struct Block; |
| 56 | 57 |
| 57 Block* fBlock; | 58 Block* fBlock; |
| 58 size_t fMinSize; | 59 size_t fMinSize; |
| 59 size_t fChunkSize; | 60 size_t fChunkSize; |
| 60 size_t fTotalCapacity; | 61 size_t fTotalCapacity; |
| 62 size_t fTotalUsed; // will be <= fTotalCapacity |
| 61 int fBlockCount; | 63 int fBlockCount; |
| 62 | 64 |
| 63 Block* newBlock(size_t bytes, AllocFailType ftype); | 65 Block* newBlock(size_t bytes, AllocFailType ftype); |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 #endif | 68 #endif |
| OLD | NEW |