Permalink
Browse files

Fixed memory leak on destruction.

  • Loading branch information...
1 parent 3495acc commit ed424b3a9f9e31b3965f70757b2eed1bf4b95eae @jrcutler jrcutler committed Apr 6, 2012
Showing with 9 additions and 0 deletions.
  1. +7 −0 Adafruit_WS2801.cpp
  2. +2 −0 Adafruit_WS2801.h
View
@@ -39,6 +39,13 @@ Adafruit_WS2801::Adafruit_WS2801(void) {
updatePins(); // Must assume hardware SPI until pins are set
}
+// Release memory (as needed):
+Adafruit_WS2801::~Adafruit_WS2801(void) {
+ if (pixels != NULL) {
+ free(pixels);
+ }
+}
+
// Activate hard/soft SPI as appropriate:
void Adafruit_WS2801::begin(void) {
if(hardwareSPI == true) {
View
@@ -23,6 +23,8 @@ class Adafruit_WS2801 {
Adafruit_WS2801(uint16_t n, uint8_t order=WS2801_RGB);
// Empty constructor; init pins/strand length/data order later:
Adafruit_WS2801();
+ // Release memory (as needed):
+ ~Adafruit_WS2801();
void
begin(void),

0 comments on commit ed424b3

Please sign in to comment.