Skip to content

Commit

Permalink
Fixes & formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
PJK committed May 19, 2015
1 parent 1fa16fc commit 4177659
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Next
---------------------
- Fixes, polishing, niceties across the code base
- Update examples

0.2.1 (2015-05-17)
---------------------
Expand Down
3 changes: 2 additions & 1 deletion examples/create_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/readfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions src/cbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cbor_item_t *cbor_load(cbor_data source,
struct _cbor_stack stack = _cbor_stack_init();

/* Target for callbacks */
struct _cbor_decoder_context context = (struct _cbor_decoder_context){
struct _cbor_decoder_context context = (struct _cbor_decoder_context) {
.stack = &stack,
.creation_failed = false,
.syntax_error = false
Expand All @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/cbor/callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/cbor/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4177659

Please sign in to comment.