blob: de78be0dbc479beeb6bacb5e18538f1e37ade30f (
plain) (
tree)
|
|
int smprintf (char ** str, const char * format, ...) { /* allocates automaticalls (: */
va_list ap, aq;
va_start(ap, format);
va_copy(aq, ap);
int len = vsnprintf(NULL, 0, format, ap);
if (!(*str = realloc(*str, len+1)))
fprintf(stderr, "[BUG] !!! realloc failed\n");
if (len != vsprintf(*str, format, ap))
fprintf(stderr, "[BUG] !!! len1 != len2\n");
va_end(ap);
va_end(aq);
return len;
}
char * startswith (char * testiranec, char * začetek) {
if (!strncmp(testiranec, začetek, strlen(začetek)))
return testiranec+strlen(začetek);
return NULL;
}
|