翻舊帳

2018年7月17日 星期二

error: version mismatch. This is Automake

簡單說, 這一包 source code 使用的 Automake 版本, 跟系統中找到的不同, 就會發生這種錯誤.

解決方法也很簡單.
進入source code目錄, 執行 autoreconf 即可.

2017年11月30日 星期四

小樂

好吃.



這家在新店家樂福旁邊的小店, 我們之前經過多次, 只覺得人聲鼎沸, 卻懶得排隊.
直到某天時機恰巧, 剛進去就坐到了最後一個空桌, 從此一試成主顧.

2017年11月28日 星期二

µPD720201 init fail on Linux

開機過程中, 掛載driver時出現 stall on CPU 2 的訊息.
/proc/bus/pci/devices 裡面看得到µPD720201的編號, 卻沒有辦法正確init.

原因很簡單, µPD720201需要外部的ROM存放FW, 如果ROM沒有上或是裡面沒有燒FW, 就會出現這個狀況.

2017年10月13日 星期五

free(): invalid next size (fast)

我參考Linux man page的code:
#define _GNU_SOURCE
#include
#include

int
main(void)
{
FILE *fp;
char *line = NULL;
size_t len = 0;
ssize_t read;

fp = fopen("/etc/motd", "r");
if (fp == NULL)
exit(EXIT_FAILURE);

while ((read = getline(&line, &len, fp)) != -1) {
printf("Retrieved line of length %zu :\n", read);
printf("%s", line);
}

free(line);
exit(EXIT_SUCCESS);
}

針對getline()產生的line buffer, 在最後將它free, 卻得到free(): invalid next size (fast).

最後我改用另一種寫法, 先malloc一塊夠大的buffer給line pointer, 然後, 然後就沒有error了.
len = 512;
line = malloc(len);
while( (ret = getline(&line, (size_t *)&len, fp)) != -1 ) {
if(line[0] == '#') continue; //comment
}
if(line != NULL) free(line);

Related Posts Plugin for WordPress, Blogger...