Skip to content

Commit

Permalink
CORE-66: In Core Ethereum, address memory management in EWM and BCS e…
Browse files Browse the repository at this point in the history
…vent handling.
  • Loading branch information
Ed Gamble committed Sep 27, 2018
1 parent 781250d commit da1fba8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
12 changes: 8 additions & 4 deletions ethereum/bcs/BREthereumBCS.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ bcsCreateInitializeBlocks (BREthereumBCS bcs,
bcs->chainTail = bcs->chain;
}

array_free(sortedBlocks);
array_free(blocks);
array_free (sortedBlocks);
array_free (blocks);
}

static void
Expand All @@ -135,8 +135,10 @@ bcsCreateInitializeTransactions (BREthereumBCS bcs,
TRANSACTION_STATUS_ERRORED == status.type ||
TRANSACTION_STATUS_PENDING == status.type);

bcsSignalTransaction(bcs, transaction);
bcsSignalTransaction (bcs, transaction);
}

array_free (transactions);
}

static void
Expand All @@ -153,8 +155,10 @@ bcsCreateInitializeLogs (BREthereumBCS bcs,
TRANSACTION_STATUS_ERRORED == status.type ||
TRANSACTION_STATUS_PENDING == status.type);

bcsSignalLog(bcs, log);
bcsSignalLog (bcs, log);
}

array_free (logs);
}

extern BREthereumBCS
Expand Down
17 changes: 15 additions & 2 deletions ethereum/bcs/BREthereumBCSEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,16 @@ bcsHandleTransactionDispatcher (BREventHandler ignore,
bcsHandleTransaction(event->bcs, event->transaction);
}

static void
bcsHandleTransactionDestroyer (BREthereumHandleTransactionEvent *event) {
transactionRelease(event->transaction);
}

static BREventType handleTransactionEventType = {
"BCS: Handle Transaction Event",
sizeof (BREthereumHandleTransactionEvent),
(BREventDispatcher) bcsHandleTransactionDispatcher
(BREventDispatcher) bcsHandleTransactionDispatcher,
(BREventDestroyer) bcsHandleTransactionDestroyer
};

extern void
Expand Down Expand Up @@ -219,10 +225,16 @@ bcsHandleLogDispatcher (BREventHandler ignore,
event->log);
}

static void
bcsHandleLogDestroyer (BREthereumHandleLogEvent *event) {
logRelease(event->log);
}

static BREventType handleLogEventType = {
"BCS: Handle Log Event",
sizeof (BREthereumHandleLogEvent),
(BREventDispatcher) bcsHandleLogDispatcher
(BREventDispatcher) bcsHandleLogDispatcher,
(BREventDestroyer) bcsHandleLogDestroyer
};

extern void
Expand Down Expand Up @@ -297,6 +309,7 @@ bcsSyncHandleProvisionDispatcher (BREventHandler ignore,

static void
bcsSyncHandleProvisionDestroyer (BREthereumHandleProvisionEvent *event) {
// syncRangeRelease (event->range);
// provisionResultRelease(event->result);
}

Expand Down
24 changes: 21 additions & 3 deletions ethereum/ewm/BREthereumEWMClientEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,16 @@ ewmClientSignalAnnounceTransactionDispatcher (BREventHandler ignore,
ewmClientHandleAnnounceTransaction(event->ewm, event->bundle, event->rid);
}

static void
ewmClientSignalAnnounceTransactionDestroyer (BREthereumEWMClientAnnounceTransactionEvent *event) {
ewmClientAnnounceTransactionBundleRelease(event->bundle);
}

static BREventType ewmClientAnnounceTransactionEventType = {
"EWM: Client Announce Transaction Event",
sizeof (BREthereumEWMClientAnnounceTransactionEvent),
(BREventDispatcher) ewmClientSignalAnnounceTransactionDispatcher
(BREventDispatcher) ewmClientSignalAnnounceTransactionDispatcher,
(BREventDestroyer) ewmClientSignalAnnounceTransactionDestroyer
};

extern void
Expand Down Expand Up @@ -498,10 +504,16 @@ ewmClientSignalAnnounceLogDispatcher (BREventHandler ignore,
ewmClientHandleAnnounceLog(event->ewm, event->bundle, event->rid);
}

static void
ewmClientSignalAnnounceLogDestroyer (BREthereumEWMClientAnnounceLogEvent *event) {
ewmClientAnnounceLogBundleRelease(event->bundle);
}

static BREventType ewmClientAnnounceLogEventType = {
"EWM: Client Announce Log Event",
sizeof (BREthereumEWMClientAnnounceLogEvent),
(BREventDispatcher) ewmClientSignalAnnounceLogDispatcher
(BREventDispatcher) ewmClientSignalAnnounceLogDispatcher,
(BREventDestroyer) ewmClientSignalAnnounceLogDestroyer
};

extern void
Expand Down Expand Up @@ -529,10 +541,16 @@ ewmClientSignalAnnounceTokenDispatcher (BREventHandler ignore,
ewmClientHandleAnnounceToken(event->ewm, event->bundle, event->rid);
}

static void
ewmClientSignalAnnounceTokenDestroyer (BREthereumEWMClientAnnounceTokenEvent *event) {
ewmClientAnnounceTokenBundleRelease(event->bundle);
}

static BREventType ewmClientAnnounceTokenEventType = {
"EWM: Client Announce Token Event",
sizeof (BREthereumEWMClientAnnounceTokenEvent),
(BREventDispatcher) ewmClientSignalAnnounceTokenDispatcher
(BREventDispatcher) ewmClientSignalAnnounceTokenDispatcher,
(BREventDestroyer) ewmClientSignalAnnounceTokenDestroyer
};

extern void
Expand Down

0 comments on commit da1fba8

Please sign in to comment.