summaryrefslogtreecommitdiff
path: root/libstore
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-11-13 21:57:31 +0000
committerMiles Bader <miles@gnu.org>1995-11-13 21:57:31 +0000
commitb8285c3b75c383031f9b7055cec6308f85251731 (patch)
treeac56f1faa88104dac47a433e0d056eae9485d092 /libstore
parent781b7dc197eaa45129fcdee410609387e63217a9 (diff)
Formerly set.c.~2~
Diffstat (limited to 'libstore')
-rw-r--r--libstore/set.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/libstore/set.c b/libstore/set.c
index c3a22e37..0efbba8e 100644
--- a/libstore/set.c
+++ b/libstore/set.c
@@ -20,13 +20,16 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include <malloc.h>
+
#include "store.h"
/* Set STORE's current runs list to (a copy of) RUNS and RUNS_LEN. */
error_t
store_set_runs (struct store *store, off_t *runs, unsigned runs_len)
{
- off_t *copy = malloc (runs_len * sizeof (off_t));
+ unsigned size = runs_len * sizeof (off_t);
+ off_t *copy = malloc (size);
if (!copy)
return ENOMEM;
@@ -34,9 +37,13 @@ store_set_runs (struct store *store, off_t *runs, unsigned runs_len)
if (store->runs)
free (store->runs);
+ bcopy (runs, copy, size);
store->runs = copy;
store->runs_len = runs_len;
+ if (store->block_size > 0)
+ _store_derive (store);
+
return 0;
}
@@ -45,11 +52,26 @@ error_t
store_set_name (struct store *store, char *name)
{
char *copy = malloc (strlen (name) + 1);
+
if (!copy)
return ENOMEM;
+
if (store->name)
free (store->name);
+
strcpy (copy, name);
store->name = copy;
+
return 0;
}
+
+/* If STORE was created using store_create, remove the reference to the
+ source from which it was created. */
+void store_close_source (struct store *store)
+{
+ if (store->source)
+ {
+ mach_port_deallocate (mach_task_self (), store->source);
+ store->source = MACH_PORT_NULL;
+ }
+}