-
Notifications
You must be signed in to change notification settings - Fork 266
EIP-712 memory allocator migration #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
apaillier-ledger
merged 6 commits into
develop
from
feat/apa/eip712_allocator_migration
Jun 24, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3a168be
Added linked-list "library"
apaillier-ledger 87cf268
Memory profiling improvements
apaillier-ledger 69a9427
Migrated EIP-712 feature to the new memory allocator
apaillier-ledger 98d418b
Removed const-qualifier on pointers arguments in function
apaillier-ledger f47666a
Added EIP-712 memory allocation cleanup
apaillier-ledger 37e3c9c
Removed legacy memory allocator
apaillier-ledger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| #include "list.h" | ||
|
|
||
| void flist_push_front(s_flist_node **list, s_flist_node *node) { | ||
| if ((list != NULL) && (node != NULL)) { | ||
| node->next = *list; | ||
| *list = node; | ||
| } | ||
| } | ||
|
|
||
| void flist_pop_front(s_flist_node **list, f_list_node_del func) { | ||
| s_flist_node *tmp; | ||
|
|
||
| if (list != NULL) { | ||
| tmp = *list; | ||
| if (tmp != NULL) { | ||
| *list = tmp->next; | ||
| if (func != NULL) func(tmp); | ||
|
apaillier-ledger marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| void flist_push_back(s_flist_node **list, s_flist_node *node) { | ||
| s_flist_node *tmp; | ||
|
|
||
| if ((list != NULL) && (node != NULL)) { | ||
| if (*list == NULL) { | ||
| *list = node; | ||
| } else { | ||
| tmp = *list; | ||
| if (tmp != NULL) { | ||
| for (; tmp->next != NULL; tmp = tmp->next) | ||
| ; | ||
| tmp->next = node; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void flist_pop_back(s_flist_node **list, f_list_node_del func) { | ||
| s_flist_node *tmp; | ||
|
|
||
| if (list != NULL) { | ||
| tmp = *list; | ||
| if (tmp != NULL) { | ||
| // only one element | ||
| if (tmp->next == NULL) { | ||
| flist_pop_front(list, func); | ||
| } else { | ||
| for (; tmp->next->next != NULL; tmp = tmp->next) | ||
| ; | ||
| if (func != NULL) func(tmp->next); | ||
| tmp->next = NULL; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void flist_insert_after(s_flist_node **list, s_flist_node *ref, s_flist_node *node) { | ||
| (void) list; | ||
| if ((ref != NULL) && (node != NULL)) { | ||
| node->next = ref->next; | ||
| ref->next = node; | ||
| } | ||
| } | ||
|
|
||
| void flist_remove(s_flist_node **list, s_flist_node *node, f_list_node_del func) { | ||
| s_flist_node *it; | ||
| s_flist_node *tmp; | ||
|
|
||
| if ((list != NULL) && (node != NULL)) { | ||
| if (node == *list) { | ||
| // first element | ||
| flist_pop_front(list, func); | ||
| } else { | ||
| it = *list; | ||
| if (it != NULL) { | ||
| for (; it->next != node; it = it->next) | ||
| ; | ||
| tmp = it->next->next; | ||
| if (func != NULL) func(it->next); | ||
| it->next = tmp; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void flist_clear(s_flist_node **list, f_list_node_del func) { | ||
| s_flist_node *tmp; | ||
| s_flist_node *next; | ||
|
|
||
| if (list != NULL) { | ||
| tmp = *list; | ||
| while (tmp != NULL) { | ||
| next = tmp->next; | ||
| if (func != NULL) func(tmp); | ||
| tmp = next; | ||
| } | ||
| *list = NULL; | ||
| } | ||
| } | ||
|
|
||
| size_t flist_size(s_flist_node *const *list) { | ||
| size_t size = 0; | ||
|
|
||
| if (list != NULL) { | ||
| for (s_flist_node *tmp = *list; tmp != NULL; tmp = tmp->next) size += 1; | ||
| } | ||
| return size; | ||
| } | ||
|
|
||
| void flist_sort(s_flist_node **list, f_list_node_cmp func) { | ||
| s_flist_node **tmp; | ||
| s_flist_node *a, *b; | ||
| bool sorted; | ||
|
|
||
| if ((list != NULL) && (func != NULL)) { | ||
| do { | ||
| sorted = true; | ||
| for (tmp = list; (*tmp != NULL) && ((*tmp)->next != NULL); tmp = &(*tmp)->next) { | ||
| a = *tmp; | ||
| b = a->next; | ||
| if (func(a, b) == false) { | ||
| *tmp = b; | ||
| a->next = b->next; | ||
| b->next = a; | ||
| sorted = false; | ||
| } | ||
| } | ||
| } while (!sorted); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #pragma once | ||
|
|
||
| #include <stdlib.h> | ||
| #include <stdbool.h> | ||
|
|
||
| /* | ||
| * Forward list (singly-linked) | ||
| */ | ||
| typedef struct flist_node { | ||
| struct flist_node *next; | ||
| } s_flist_node; | ||
|
|
||
| typedef void (*f_list_node_del)(s_flist_node *node); | ||
| typedef bool (*f_list_node_cmp)(const s_flist_node *a, const s_flist_node *b); | ||
|
|
||
| /** | ||
| * Add a new node at the front of the list | ||
| * | ||
| * @param[in,out] list pointer to the list | ||
| * @param[out] node new node to add | ||
| */ | ||
| void flist_push_front(s_flist_node **list, s_flist_node *node); | ||
|
|
||
| /** | ||
| * Remove the first node from the list | ||
| * | ||
| * @param[in,out] list pointer to the list | ||
| * @param[in] func pointer to the node deletion function | ||
| */ | ||
| void flist_pop_front(s_flist_node **list, f_list_node_del func); | ||
|
|
||
| /** | ||
| * Add a new node at the back of the list | ||
| * | ||
| * @param[in,out] list pointer to the list | ||
| * @param[in,out] node new node to add | ||
| */ | ||
| void flist_push_back(s_flist_node **list, s_flist_node *node); | ||
|
|
||
| /** | ||
| * Remove the last node from the list | ||
| * | ||
| * @param[in,out] list pointer to the list | ||
| * @param[in] func pointer to the node deletion function | ||
| */ | ||
| void flist_pop_back(s_flist_node **list, f_list_node_del func); | ||
|
|
||
| /** | ||
| * Insert a new node after a given list node (reference) | ||
| * | ||
| * @param[] list pointer to the list | ||
| * @param[in,out] ref reference node | ||
| * @param[in,out] node new node to add | ||
| */ | ||
| void flist_insert_after(s_flist_node **list, s_flist_node *ref, s_flist_node *node); | ||
|
|
||
| /** | ||
| * Remove a given node from the list | ||
| * | ||
| * @param[in,out] list pointer to the list | ||
| * @param[out] node node to remove | ||
| * @param[in] func pointer to the node deletion function | ||
| */ | ||
| void flist_remove(s_flist_node **list, s_flist_node *node, f_list_node_del func); | ||
|
|
||
| /** | ||
| * Remove all nodes from the list | ||
| * | ||
| * @param[in,out] list pointer to the list | ||
| * @param[in] func pointer to the node deletion function | ||
| */ | ||
| void flist_clear(s_flist_node **list, f_list_node_del func); | ||
|
|
||
| /** | ||
| * Get the list size | ||
| * | ||
| * @param[in] list pointer to the list | ||
| */ | ||
| size_t flist_size(s_flist_node *const *list); | ||
|
|
||
| /** | ||
| * Sort the list | ||
| * | ||
| * @param[in,out] list pointer to the list | ||
| * @param[in] func pointer to the node comparison function | ||
| */ | ||
| void flist_sort(s_flist_node **list, f_list_node_cmp func); | ||
|
|
||
| /* | ||
| * List (doubly-linked) | ||
| * TODO: add functions | ||
| */ | ||
| typedef struct list_node { | ||
|
cedelavergne-ledger marked this conversation as resolved.
|
||
| s_flist_node _list; | ||
| struct list_node *prev; | ||
| } s_list_node; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.