Surely it's sufficient to set <code>buf[0] = '\0';</code> - much cheaper than memset() !