Improve comments; cleanup

This commit is contained in:
Michal Moskal 2015-10-25 13:09:24 -07:00
parent 98ffcc1fd1
commit 7b82f3e8eb
3 changed files with 9 additions and 7 deletions

View file

@ -21,11 +21,15 @@ struct StringData : RefCounted
* 1) std::shared_ptr is not yet availiable on the ARMCC compiler
* 2) to reduce memory footprint - we don't need many of the other features in the std library
* 3) it makes an interestin case study for anyone interested in seeing how it works!
* 4) we need explicit reference counting to inter-op with low-level application langauge runtimes
* 5) the reference counting needs to also work for read-only, flash-resident strings
*/
class ManagedString
{
// Internally we record the string as a char *, but control access to this to proide immutability
// and reference counting.
// StringData contains the reference count, the length, follwed by char[] data, all in one block.
// When referece count is 0xffff, then it's read only and should not be counted.
// Otherwise the block was malloc()ed.
// We control access to this to proide immutability and reference counting.
StringData *ptr;
public:
@ -140,7 +144,7 @@ class ManagedString
*
* Free this ManagedString, and decrement the reference count to the
* internal character buffer. If we're holding the last reference,
* also free the character buffer and reference counter.
* also free the character buffer.
*/
~ManagedString();
@ -282,7 +286,7 @@ class ManagedString
*/
const char *toCharArray() const
{
ptr->isReadOnly(); // this performs sanity checks on refCount
// ptr->isReadOnly(); // this performs sanity checks on refCount
return ptr->data;
}

View file

@ -3,8 +3,6 @@
#include "mbed.h"
#include "MicroBit.h"
#define printf(...) uBit.serial.printf(__VA_ARGS__)
static const char empty[] __attribute__ ((aligned (4))) = "\xff\xff\0\0\0";
/**

View file

@ -7,11 +7,11 @@
#include "MicroBit.h"
static const uint8_t empty[] __attribute__ ((aligned (4))) = { 0xff, 0xff, 1, 1, 0, 0 };
/*
* The null image. We actally create a small one byte buffer here, just to keep NULL pointers out of the equation.
*/
static const uint8_t empty[] __attribute__ ((aligned (4))) = { 0xff, 0xff, 1, 1, 0, 0 };
MicroBitImage MicroBitImage::EmptyImage((ImageData*)(void*)empty);
/**