Index: src/core/SkSmallAllocator.h |
diff --git a/src/core/SkSmallAllocator.h b/src/core/SkSmallAllocator.h |
index 2eddb510cd050ed6cce16915fab0560c847f0404..49f155e48eebfdd5c2d80f6520c65b576ad1406c 100644 |
--- a/src/core/SkSmallAllocator.h |
+++ b/src/core/SkSmallAllocator.h |
@@ -131,6 +131,21 @@ public: |
return rec->fObj; |
} |
+ /* |
+ * Free the memory reserved last without calling the destructor. |
+ * Can be used in a nested way, i.e. after reserving A and B, calling |
+ * freeLast once will free B and calling it again will free A. |
+ * Note: the available memory will not be made available to future |
+ * allocations. |
+ */ |
+ void freeLast() { |
+ SkASSERT(fNumObjects > 0); |
+ Rec* rec = &fRecs[fNumObjects - 1]; |
+ sk_free(rec->fHeapStorage); |
+ |
+ fNumObjects--; |
+ } |
+ |
private: |
struct Rec { |
void* fObj; |