Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Reuse the same sbuf for every file, clearing the buffer each time.
Will Andrews committed 15 years ago
commit 6d3c8c054302d323aa174833a7f1516cad722644
parent 15725d3b2a0f0c9f5e7c493fa5551a06b610dc63
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;