edits
[iotcloud.git] / version2 / src / C / NewKey.cc
index 25798394ec7f37bc752a896e91dacaba8445a031..a3a1a87c8dbe81007c5711b0b1a219b83c85116d 100644 (file)
@@ -12,13 +12,15 @@ NewKey::~NewKey() {
        delete key;
 }
 
-Entry *decode(Slot *slot, ByteBuffer *bb) {
+Entry *NewKey_decode(Slot *slot, ByteBuffer *bb) {
        int keylength = bb->getInt();
        Array<char> *key = new Array<char>(keylength);
        bb->get(key);
        int64_t machineid = bb->getLong();
-
-       return new NewKey(slot, IoTString_shallow(key), machineid);
+       IoTString *str = IoTString_shallow(key);
+       NewKey *newkey = new NewKey(slot, str, machineid);
+       delete str;
+       return newkey;
 }
 
 Entry *NewKey::getCopy(Slot *s) { return new NewKey(s, new IoTString(key), machineid); }