edits
[iotcloud.git] / version2 / src / C / Slot.cc
index ea698cc7e97b4de212934693f47149b76d2970d0..3f752262b46ac7db2a31ca1feb9cf770cabebb0d 100644 (file)
@@ -5,6 +5,7 @@
 #include "CloudComm.h"
 #include "Table.h"
 #include "LastMessage.h"
+#include "Mac.h"
 
 Slot::Slot(Table *_table, int64_t _seqnum, int64_t _machineid, Array<char> *_prevhmac, Array<char> *_hmac, int64_t _localSequenceNumber) :
        seqnum(_seqnum),
@@ -78,8 +79,8 @@ Vector<Entry *> *Slot::getEntries() {
        return entries;
 }
 
-Slot *Slotdecode(Table *table, Array<char> *array, Mac *mac) {
-       mac->update(array, HMAC_SIZE, array.length - HMAC_SIZE);
+Slot *Slot_decode(Table *table, Array<char> *array, Mac *mac) {
+       mac->update(array, HMAC_SIZE, array->length() - HMAC_SIZE);
        Array<char> *realmac = mac->doFinal();
 
        ByteBuffer *bb = ByteBuffer_wrap(array);
@@ -111,11 +112,12 @@ Array<char> *Slot::encode(Mac *mac) {
        bb->putLong(seqnum);
        bb->putLong(machineid);
        bb->putInt(entries->size());
-       for (Entry *entry : entries) {
+       for(uint ei=0; ei < entries->size(); ei++) {
+               Entry * entry = entries->get(ei);
                entry->encode(bb);
        }
        /* Compute our HMAC */
-       mac->update(array, HMAC_SIZE, array.length - HMAC_SIZE);
+       mac->update(array, HMAC_SIZE, array->length() - HMAC_SIZE);
        Array<char> *realmac = mac->doFinal();
        hmac = realmac;
        bb->position(0);
@@ -132,7 +134,8 @@ Array<char> *Slot::encode(Mac *mac) {
 
 Vector<Entry *> *Slot::getLiveEntries(bool resize) {
        Vector<Entry *> *liveEntries = new Vector<Entry *>();
-       for (Entry *entry : entries) {
+       for(uint ei=0; ei < entries->size(); ei++) {
+               Entry * entry = entries->get(ei);
                if (entry->isLive()) {
                        if (!resize || entry->getType() != TypeTableStatus)
                                liveEntries->add(entry);