替代g中的g_array_append_val

时间:2016-11-25 12:14:18

标签: c compression

我正在编写一个实现LZ77压缩算法的程序。我正在使用this program 作为我的参考,我正在尝试将函数从“glib”库切换到C的更多标准函数。现在我无法替换“g_array_append_val”,因为此函数正在执行的转换是不兼容的。任何帮助将不胜感激,这是我目前的计划:

typedef struct {
short start;
short length;
char first_mismatch;
} reference;
char *lookahead = NULL;
reference matchref = {0, 0, *lookahead};
GArray *symbols = g_array_new(false, false, sizeof(reference));
g_array_append_val(symbols, matchref);

这就是我的尝试:

typedef struct {
short start;
short length;
char first_mismatch;
} reference;
char *lookahead = NULL;
reference matchref = {0, 0, *lookahead};
reference *symbols;
symbols=(reference *)malloc(sizeof(reference));
strcat(symbols, matchref);

任何帮助将不胜感激,提前谢谢!

0 个答案:

没有答案