Skip to content
Snippets Groups Projects
Commit 41776593 authored by PJK's avatar PJK
Browse files

Fixes & formatting

parent 1fa16fc2
Branches
Tags v0.2.1
No related merge requests found
Next
---------------------
- Fixes, polishing, niceties across the code base
- Update examples
0.2.1 (2015-05-17)
---------------------
......
......@@ -23,7 +23,8 @@ int main(int argc, char * argv[])
});
/* Output: `length` bytes of data in the `buffer` */
unsigned char * buffer;
size_t buffer_size, length = cbor_serialize_alloc(root, &buffer, &buffer_size);
size_t buffer_size,
length = cbor_serialize_alloc(root, &buffer, &buffer_size);
fwrite(buffer, 1, length, stdout);
free(buffer);
......
......@@ -22,7 +22,7 @@ int main(int argc, char * argv[])
unsigned char * buffer = malloc(length);
fread(buffer, length, 1, f);
/* Assuming `buffer` contains `info.st_size` bytes of input data */
/* Assuming `buffer` contains `length` bytes of input data */
struct cbor_load_result result;
cbor_item_t * item = cbor_load(buffer, length, &result);
/* Pretty-print the result */
......
......@@ -73,7 +73,8 @@ cbor_item_t *cbor_load(cbor_data source,
} else {
result->error = (struct cbor_error) {
.code = CBOR_ERR_NOTENOUGHDATA,
.position = result->read};
.position = result->read
};
goto error;
}
......
......@@ -46,14 +46,14 @@ typedef void(*cbor_bool_callback)(void *, bool);
/** Callback bundle -- passed to the decoder */
struct cbor_callbacks {
/** Unsigned int */
cbor_int64_callback uint64;
/** Unsigned int */
cbor_int32_callback uint32;
/** Unsigned int */
cbor_int8_callback uint8;
/** Unsigned int */
cbor_int16_callback uint16;
/** Unsigned int */
cbor_int32_callback uint32;
/** Unsigned int */
cbor_int64_callback uint64;
/** Negative int */
cbor_int64_callback negint64;
......
......@@ -132,10 +132,15 @@ union cbor_item_metadata {
struct _cbor_float_ctrl_metadata float_ctrl_metadata;
};
/** The item handle */
typedef struct cbor_item_t {
/** Discriminated by type */
union cbor_item_metadata metadata;
/** Reference count - initialize to 0 */
size_t refcount;
/** Major type discriminator */
cbor_type type;
/** Raw data block - interpretation depends on metadata */
unsigned char * data;
} cbor_item_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment