fixed compile warnings, fixed sml_seq related bug
This commit is contained in:
parent
4339767c49
commit
17dcb0e993
3 changed files with 7 additions and 7 deletions
|
@ -44,7 +44,6 @@ void sml_sequence_write(sml_sequence *seq, sml_buffer *buf, void (*elem_write) (
|
|||
void sml_sequence_free(sml_sequence *seq);
|
||||
void sml_sequence_add(sml_sequence *list, void *new_entry);
|
||||
|
||||
|
||||
typedef struct sml_list_entry {
|
||||
octet_string *obj_name;
|
||||
sml_status *status; // optional
|
||||
|
|
|
@ -53,7 +53,7 @@ sml_sequence *sml_sequence_parse(sml_buffer *buf,
|
|||
|
||||
error:
|
||||
buf->error = 1;
|
||||
sml_sequence_free(seq->elem_free);
|
||||
sml_sequence_free(seq);
|
||||
return 0;
|
||||
}
|
||||
void sml_sequence_write(sml_sequence *seq, sml_buffer *buf, void (*elem_write) (void *elem, sml_buffer *buf)) {
|
||||
|
@ -72,6 +72,7 @@ void sml_sequence_write(sml_sequence *seq, sml_buffer *buf, void (*elem_write) (
|
|||
|
||||
void sml_sequence_free(sml_sequence *seq) {
|
||||
if (seq) {
|
||||
|
||||
int i;
|
||||
for (i = 0; i < seq->elems_len; i++) {
|
||||
seq->elem_free((seq->elems)[i]);
|
||||
|
|
|
@ -109,24 +109,24 @@ TEST(sml_sequence, init) {
|
|||
}
|
||||
|
||||
TEST(sml_sequence, parse_octet_string) {
|
||||
hex2binary("720648616C6C6F0648616C6C6F", sml_buf_get_current_buf(buf));
|
||||
hex2binary("720648616C6C6F0648616C6C6F", sml_buf_get_current_buf(buf));
|
||||
|
||||
sml_sequence *seq = sml_sequence_parse(buf, &sml_octet_string_parse, &sml_octet_string_free);
|
||||
sml_sequence *seq = sml_sequence_parse(buf, (void *) &sml_octet_string_parse, (void (*)(void *))&sml_octet_string_free);
|
||||
TEST_ASSERT_NOT_NULL(seq);
|
||||
TEST_ASSERT_EQUAL(2, seq->elems_len);
|
||||
}
|
||||
|
||||
TEST(sml_sequence, write_octet_string) {
|
||||
sml_sequence *seq = sml_sequence_init(&sml_octet_string_free);
|
||||
sml_sequence *seq = sml_sequence_init((void (*)(void *))&sml_octet_string_free);
|
||||
sml_sequence_add(seq, sml_octet_string_init((unsigned char *)"Hallo", 5));
|
||||
sml_sequence_add(seq, sml_octet_string_init((unsigned char *)"Hallo", 5));
|
||||
|
||||
sml_sequence_write(seq, buf, &sml_octet_string_write);
|
||||
sml_sequence_write(seq, buf, (void (*)(void *, sml_buffer *))&sml_octet_string_write);
|
||||
expected_buf(buf, "720648616C6C6F0648616C6C6F", 13);
|
||||
}
|
||||
|
||||
TEST(sml_sequence, free_octet_string) {
|
||||
sml_sequence *seq = sml_sequence_init(&sml_octet_string_free);
|
||||
sml_sequence *seq = sml_sequence_init((void (*)(void *))&sml_octet_string_free);
|
||||
sml_sequence_add(seq, sml_octet_string_init((unsigned char *)"Hallo", 5));
|
||||
sml_sequence_free(seq);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue