Module Name:    src
Committed By:   rillig
Date:           Sun Dec 13 20:57:17 UTC 2020

Modified Files:
        src/usr.bin/make: lst.c lst.h

Log Message:
make(1): rename Vector.priv_cap to cap

There is no use case for accessing or even modifying the capacity of a
vector, therefore there is no need to hide it using the prefix "priv_".
This way, the member names are aligned between Buffer and Vector.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/lst.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/make/lst.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.100 src/usr.bin/make/lst.c:1.101
--- src/usr.bin/make/lst.c:1.100	Fri Dec  4 20:11:48 2020
+++ src/usr.bin/make/lst.c	Sun Dec 13 20:57:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.100 2020/12/04 20:11:48 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.101 2020/12/13 20:57:17 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.100 2020/12/04 20:11:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.101 2020/12/13 20:57:17 rillig Exp $");
 
 static ListNode *
 LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -256,9 +256,9 @@ void
 Vector_Init(Vector *v, size_t itemSize)
 {
 	v->len = 0;
-	v->priv_cap = 10;
+	v->cap = 10;
 	v->itemSize = itemSize;
-	v->items = bmake_malloc(v->priv_cap * v->itemSize);
+	v->items = bmake_malloc(v->cap * v->itemSize);
 }
 
 /* Add space for a new item to the vector and return a pointer to that space.
@@ -266,9 +266,9 @@ Vector_Init(Vector *v, size_t itemSize)
 void *
 Vector_Push(Vector *v)
 {
-	if (v->len >= v->priv_cap) {
-		v->priv_cap *= 2;
-		v->items = bmake_realloc(v->items, v->priv_cap * v->itemSize);
+	if (v->len >= v->cap) {
+		v->cap *= 2;
+		v->items = bmake_realloc(v->items, v->cap * v->itemSize);
 	}
 	v->len++;
 	return Vector_Get(v, v->len - 1);

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.92 src/usr.bin/make/lst.h:1.93
--- src/usr.bin/make/lst.h:1.92	Fri Dec  4 20:11:48 2020
+++ src/usr.bin/make/lst.h	Sun Dec 13 20:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.92 2020/12/04 20:11:48 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.93 2020/12/13 20:57:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -98,8 +98,8 @@ struct ListNode {
 };
 
 struct List {
-	ListNode *first;	/* first node in list */
-	ListNode *last;		/* last node in list */
+	ListNode *first;
+	ListNode *last;
 };
 
 /* Free the datum of a node, called before freeing the node itself. */
@@ -173,9 +173,9 @@ void *Lst_Dequeue(List *);
  * access. */
 typedef struct Vector {
 	void *items;		/* memory holding the items */
-	size_t itemSize;	/* size of a single item in bytes */
+	size_t itemSize;	/* size of a single item */
 	size_t len;		/* number of actually usable elements */
-	size_t priv_cap;	/* capacity */
+	size_t cap;		/* capacity */
 } Vector;
 
 void Vector_Init(Vector *, size_t);

Reply via email to