Update comments and error code values
This commit is contained in:
@@ -29,11 +29,12 @@
|
|||||||
#define ERROR_CONTEXT_LEN 60
|
#define ERROR_CONTEXT_LEN 60
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Error codes
|
Return codes on different errors:
|
||||||
|
|
||||||
EARLY_EOF - End of file unexpectedly reached
|
EARLY_EOF - End of file unexpectedly reached
|
||||||
UNEXPECTED_CHAR - Unexpected character encountered
|
UNEXPECTED_CHAR - Unexpected character encountered
|
||||||
*/
|
*/
|
||||||
#define EARLY_EOF 202
|
#define EARLY_EOF 200
|
||||||
#define UNEXPECTED_CHAR 200
|
#define UNEXPECTED_CHAR 201
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#ifndef _UTIL_H
|
#ifndef _UTIL_H
|
||||||
#define _UTIL_H
|
#define _UTIL_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h> // size_t
|
||||||
#include <stdio.h>
|
#include <stdio.h> // FILE*
|
||||||
|
|
||||||
__attribute__((__noreturn__)) void err_ctx(int exit_code, FILE* fp, const char* format, ...);
|
__attribute__((__noreturn__)) void err_ctx(int exit_code, FILE* fp, const char* format, ...);
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void print_object(obj_t obj, int cur_indent, int indent_amount);
|
|||||||
It seems to work well because 33 is coprime to
|
It seems to work well because 33 is coprime to
|
||||||
2^32 and 2^64 (any odd number except 1 is),
|
2^32 and 2^64 (any odd number except 1 is),
|
||||||
which probably improves the distribution (I'm
|
which probably improves the distribution (I'm
|
||||||
not a mathematician so I can't prove it this).
|
not a mathematician so I can't prove this).
|
||||||
Multiplying a number n by 33 is the same as
|
Multiplying a number n by 33 is the same as
|
||||||
bitshifting by 5 and adding n, which is faster
|
bitshifting by 5 and adding n, which is faster
|
||||||
than multiplying by, say, 37. Maybe any 2^x±1
|
than multiplying by, say, 37. Maybe any 2^x±1
|
||||||
@@ -112,6 +112,9 @@ bool obj_insert(obj_t m, char* const key, struct json_value* value)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Free memory allocated for json_value val
|
||||||
|
*/
|
||||||
void json_value_delete(struct json_value val)
|
void json_value_delete(struct json_value val)
|
||||||
{
|
{
|
||||||
switch (val.type) {
|
switch (val.type) {
|
||||||
@@ -140,7 +143,7 @@ void json_value_delete(struct json_value val)
|
|||||||
/*
|
/*
|
||||||
Free memory allocated for obj
|
Free memory allocated for obj
|
||||||
|
|
||||||
TODO: recurively delete children objects
|
Recursively deletes children objects
|
||||||
*/
|
*/
|
||||||
void obj_delete(obj_t* m)
|
void obj_delete(obj_t* m)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user