From 0da41dbf5bdf9614a3d2f1d3ebd959221bbac44b Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Tue, 25 Aug 2009 16:03:59 +0000 Subject: [PATCH] add detach() method git-svn-id: http://skia.googlecode.com/svn/trunk@334 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkTDArray.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h index 5f6bbd8..954bcf8 100644 --- a/include/core/SkTDArray.h +++ b/include/core/SkTDArray.h @@ -86,6 +86,17 @@ public: SkTSwap(fCount, other.fCount); } + /** Return a ptr to the array of data, to be freed with sk_free. This also + resets the SkTDArray to be empty. + */ + T* detach() { + T* array = fArray; + fArray = NULL; + fReserve = fCount = 0; + SkDEBUGCODE(fData = NULL;) + return array; + } + bool isEmpty() const { return fCount == 0; } int count() const { return fCount; } T* begin() const { return fArray; } -- 2.7.4