- strcpy(filename, path);
- if (filename[len - 1] != '/')
- filename[len++] = '/';
- for(i = 0; i < 8; i++) {
- sprintf(filename + len++, "%x",
- (unsigned char)(hash & 0xf));
+ strbuf_addstr(&filename, path);
+ strbuf_ensure_end(&filename, '/');
+ for (i = 0; i < 8; i++) {
+ strbuf_addf(&filename, "%x", (unsigned char)(hash & 0xf));