Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): rename Vector.priv_cap to cap
details: https://anonhg.NetBSD.org/src/rev/e766d5a0c795
branches: trunk
changeset: 979110:e766d5a0c795
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 13 20:57:17 2020 +0000
description:
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.
diffstat:
usr.bin/make/lst.c | 14 +++++++-------
usr.bin/make/lst.h | 10 +++++-----
2 files changed, 12 insertions(+), 12 deletions(-)
diffs (75 lines):
diff -r e91737f2d79c -r e766d5a0c795 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c Sun Dec 13 20:40:38 2020 +0000
+++ b/usr.bin/make/lst.c Sun Dec 13 20:57:17 2020 +0000
@@ -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 @@
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 @@
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);
diff -r e91737f2d79c -r e766d5a0c795 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h Sun Dec 13 20:40:38 2020 +0000
+++ b/usr.bin/make/lst.h Sun Dec 13 20:57:17 2020 +0000
@@ -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 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 @@
* 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);
Home |
Main Index |
Thread Index |
Old Index