Skip to content

Commit

Permalink
use a local buffer to avoid free
Browse files Browse the repository at this point in the history
  • Loading branch information
Geolm committed Feb 26, 2024
1 parent d6d86a4 commit f8cbb50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ TEST adaptive_model(void)

const uint32_t data[num_elements] = {0, 0, 15, 15, 15, 15, 3, 3, 2, 1, 15, 15, 15, 15, 15, 0, 0, 0, 8, 3};
const uint8_t reference_compressed_data[9] = {0x0, 0xff, 0xf7,0x33, 0x28, 0x66, 0xe6, 0x3, 0x1f};
uint8_t buffer[256];

ac_set_buffer(codec, 1000, NULL);
ac_set_buffer(codec, 256, (uint8_t*)buffer);
ac_start_encoder(codec);

for(uint32_t i=0; i<num_elements; ++i)
Expand All @@ -27,8 +28,6 @@ TEST adaptive_model(void)
uint32_t compressed_size = ac_stop_encoder(codec);
uint8_t* compressed_buffer = ac_get_buffer(codec);

printf("adaptive_model\n uncompressed size : %zu\n compressed buffer size : %d\n ratio : %f\n", sizeof(data), compressed_size, ((float)sizeof(data)) / (float)compressed_size);

ASSERT_EQ(9, compressed_size);

for(uint32_t i=0; i<compressed_size; ++i)
Expand Down

0 comments on commit f8cbb50

Please sign in to comment.