void syslog(....) { char *str; int str_len; .... str = malloc(str_len + 1); .... str = realloc(str, ++str_len + 1); if (!str) { warning("realloc failed: '%s'", strerror(errno)); return; } .... }