Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Reuse the same sbuf for every file, clearing the buffer each time.
Will Andrews committed 14 years ago
commit a4148518f1768d559bde1906277b585703a4294b
parent 5bc6216
1 file changed +3 -2
modified libpkg/packing.c
@@ -121,20 +121,20 @@ packing_append_tree(struct packing *pack, const char *treepath, const char *newr
	if (fts == NULL)
		goto cleanup;

+
	sb = sbuf_new_auto();
	while ((fts_e = fts_read(fts)) != NULL) {
		switch(fts_e->fts_info) {
		case FTS_F:
			/* Skip entries that are shorter than the tree itself */
			if (fts_e->fts_pathlen <= treelen)
				break;
-
			sb = sbuf_new_auto();
+
			sbuf_clear(sb);
			/* Strip the prefix to obtain the target path */
			if (newroot) /* Prepend a root if one is specified */
				sbuf_cat(sb, newroot);
			sbuf_cat(sb, fts_e->fts_path + treelen + 1 /* skip trailing slash */);
			sbuf_finish(sb);
			packing_append_file(pack, fts_e->fts_name, sbuf_get(sb));
-
			sbuf_free(sb);
			break;
		case FTS_DNR:
		case FTS_ERR:
@@ -146,6 +146,7 @@ packing_append_tree(struct packing *pack, const char *treepath, const char *newr
			break;
		}
	}
+
	sbuf_free(sb);
cleanup:
	fts_close(fts);
	return EPKG_OK;