diff place.c @ 13:120629a5d6bf

seenfile -> placefile (clearer)
author David A. Holland
date Sun, 19 Dec 2010 19:49:43 -0500
parents 6c15ca895585
children 5045b9678bb0
line wrap: on
line diff
--- a/place.c	Sun Dec 19 19:39:26 2010 -0500
+++ b/place.c	Sun Dec 19 19:49:43 2010 -0500
@@ -11,51 +11,52 @@
 #define BUILTIN_LINE      1
 #define COMMANDLINE_LINE  2
 
-struct seenfile {
+struct placefile {
 	struct place includedfrom;
 	char *name;
 	bool fromsystemdir;
 };
-DECLARRAY(seenfile);
-DEFARRAY(seenfile, );
+DECLARRAY(placefile);
+DEFARRAY(placefile, );
 
-static struct seenfilearray seenfiles;
+static struct placefilearray placefiles;
 static bool overall_failure;
 
 ////////////////////////////////////////////////////////////
 // seenfiles
 
 static
-struct seenfile *
-seenfile_create(const struct place *from, char *name, bool fromsystemdir)
+struct placefile *
+placefile_create(const struct place *from, const char *name,
+		 bool fromsystemdir)
 {
-	struct seenfile *sf;
+	struct placefile *pf;
 
-	sf = domalloc(sizeof(*sf));
-	sf->includedfrom = *from;
-	sf->name = name;
-	sf->fromsystemdir = fromsystemdir;
-	return sf;
+	pf = domalloc(sizeof(*pf));
+	pf->includedfrom = *from;
+	pf->name = dostrdup(name);
+	pf->fromsystemdir = fromsystemdir;
+	return pf;
 }
 
 static
 void
-seenfile_destroy(struct seenfile *sf)
+placefile_destroy(struct placefile *pf)
 {
-	free(sf->name);
-	free(sf);
+	free(pf->name);
+	free(pf);
 }
 
-DESTROYALL_ARRAY(seenfile, );
+DESTROYALL_ARRAY(placefile, );
 
-struct seenfile *
-place_seen_file(const struct place *place, char *file, bool issystem)
+const struct placefile *
+place_addfile(const struct place *place, const char *file, bool issystem)
 {
-	struct seenfile *sf;
+	struct placefile *pf;
 
-	sf = seenfile_create(place, file, issystem);
-	seenfilearray_add(&seenfiles, sf, NULL);
-	return sf;
+	pf = placefile_create(place, file, issystem);
+	placefilearray_add(&placefiles, pf, NULL);
+	return pf;
 }
 
 ////////////////////////////////////////////////////////////
@@ -149,12 +150,12 @@
 void
 place_init(void)
 {
-	seenfilearray_init(&seenfiles);
+	placefilearray_init(&placefiles);
 }
 
 void
 place_cleanup(void)
 {
-	seenfilearray_destroyall(&seenfiles);
-	seenfilearray_cleanup(&seenfiles);
+	placefilearray_destroyall(&placefiles);
+	placefilearray_cleanup(&placefiles);
 }