Comment

Comment by Joker_vD

    if (scanf("%9lu",&len) < 1) barf();  /* >999999999 bytes is bad */
    if (getchar() != ':') barf();
    buf = malloc(len + 1);       /* malloc(0) is not portable */
    if (!buf) barf();
    if (fread(buf,1,len,stdin) < len) barf();
    if (getchar() != ',') barf();
Ah, the wonders of error-handling in C. Also, I wonder what's wrong with

    buf = malloc(len ? len : 1);
parent Joker_vD 3 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton