aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkTDArray.h
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-08-25 16:03:59 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-08-25 16:03:59 +0000
commit0da41dbf5bdf9614a3d2f1d3ebd959221bbac44b (patch)
tree1382a5ab533e2f5ec7c82a3ed10c79c9215b8b7b /include/core/SkTDArray.h
parent1cdcb5138f9b70aff547ea1c3af96f0c90b12f8f (diff)
add detach() method
git-svn-id: http://skia.googlecode.com/svn/trunk@334 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkTDArray.h')
-rw-r--r--include/core/SkTDArray.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h
index 5f6bbd8612..954bcf899d 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; }