Skip to content

Commit

Permalink
more const
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-jentzsch committed Dec 29, 2019
1 parent 38c5f44 commit 0415855
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/core/util/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ d_token_t* parsed_next_item(json_ctx_t* jp, d_type_t type, d_key_t key, int pare
}

int parse_key(json_ctx_t* jp) {
char* start = jp->c;
int r;
const char* start = jp->c;
int r;
while (true) {
switch (*(jp->c++)) {
case 0: return -2;
Expand Down Expand Up @@ -429,9 +429,9 @@ int parse_number(json_ctx_t* jp, d_token_t* item) {
}

int parse_string(json_ctx_t* jp, d_token_t* item) {
char* start = jp->c;
size_t l, i;
int n;
const char* start = jp->c;
size_t l, i;
int n;

while (true) {
switch (*(jp->c++)) {
Expand Down Expand Up @@ -594,7 +594,7 @@ json_ctx_t* parse_json(char* js) {
_free(parser); // also free the parse since it does not make sense to parse now.
return NULL; // NULL means no memory
} //
int res = parse_object(parser, -1, 0); // now parse starting without parent (-1)
const int res = parse_object(parser, -1, 0); // now parse starting without parent (-1)
if (res < 0) { // error parsing?
json_free(parser); // clean up
return NULL; // and return null
Expand All @@ -603,9 +603,9 @@ json_ctx_t* parse_json(char* js) {
return parser;
}

static int find_end(char* str) {
int l = 0;
char* c = str;
static int find_end(const char* str) {
int l = 0;
const char* c = str;
while (*c != 0) {
switch (*(c++)) {
case '{':
Expand Down Expand Up @@ -689,7 +689,7 @@ char* d_create_json(d_token_t* item) {
return NULL;
}

str_range_t d_to_json(d_token_t* item) {
str_range_t d_to_json(const d_token_t* item) {
str_range_t s;
if (item) {
s.data = (char*) item->data;
Expand Down
2 changes: 1 addition & 1 deletion src/core/util/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ json_ctx_t* parse_binary(const bytes_t* data); /**< parses t
json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */
json_ctx_t* parse_json(char* js); /**< parses json-data, which needs to be freed after usage! */
void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */
str_range_t d_to_json(d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */
str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */
char* d_create_json(d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/

json_ctx_t* json_create();
Expand Down
8 changes: 4 additions & 4 deletions src/verifier/eth1/basic/trie.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ typedef struct trie_codec {
* This is a Patricia Merkle Tree.
*/
typedef struct trie {
in3_hasher_t hasher; /**< hash-function. */
trie_codec_t* codec; /**< encoding of the nocds. */
uint8_t root[32]; /**< The root-hash. */
trie_node_t* nodes; /**< linked list of containes nodes */
in3_hasher_t hasher; /**< hash-function. */
trie_codec_t* codec; /**< encoding of the nocds. */
bytes32_t root; /**< The root-hash. */
trie_node_t* nodes; /**< linked list of containes nodes */
} trie_t;

/**
Expand Down

0 comments on commit 0415855

Please sign in to comment.