no libc, start on socket x11
This commit is contained in:
+6
-7
@@ -44,9 +44,9 @@ struct com_lzw_table com_lzw_infer_table(const char *datain, uint32_t sizein) {
|
||||
if (!code_found) {
|
||||
if (table_size >= table_cap) {
|
||||
/* TODO: Ref to prev table gets missed, memory leak scenario */
|
||||
if (!(table = com_std_realloc(
|
||||
table, sizeof(struct com_lzw_table_entry) *
|
||||
(table_cap + COM_LZW_TABLE_CAP_GROW))))
|
||||
if (!(table = com_std_alloc(table,
|
||||
sizeof(struct com_lzw_table_entry) *
|
||||
(table_cap + COM_LZW_TABLE_CAP_GROW))))
|
||||
goto ERR_ALLOC_INIT_TABLE;
|
||||
|
||||
table_cap += COM_LZW_TABLE_CAP_GROW;
|
||||
@@ -68,14 +68,14 @@ struct com_lzw_table com_lzw_infer_table(const char *datain, uint32_t sizein) {
|
||||
|
||||
ERR_ALLOC_INIT_TABLE:
|
||||
if (table_cap > 0)
|
||||
com_std_free(table);
|
||||
com_std_alloc(table, 0);
|
||||
return (struct com_lzw_table){0};
|
||||
}
|
||||
|
||||
void com_lzw_free_table(struct com_lzw_table *table) {
|
||||
if (!table->table)
|
||||
return;
|
||||
com_std_free(table->table);
|
||||
com_std_alloc(table->table, 0);
|
||||
table->size = 0;
|
||||
table->cap = 0;
|
||||
table->init_size = 0;
|
||||
@@ -131,8 +131,7 @@ bool com_lzw_compress(const struct com_lzw_table *table, const char *datain,
|
||||
|
||||
if (output_size == output_cap && output_bitshift + codesize > 8) {
|
||||
/* TODO: catch alloc failure */
|
||||
output =
|
||||
com_std_realloc(output, output_cap + COM_LZW_OUTPUT_CAP_GROWTH);
|
||||
output = com_std_alloc(output, output_cap + COM_LZW_OUTPUT_CAP_GROWTH);
|
||||
output_cap += COM_LZW_OUTPUT_CAP_GROWTH;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user