Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: name memory allocation functions c...
details: https://anonhg.NetBSD.org/src/rev/a7c713d93448
branches: trunk
changeset: 982139:a7c713d93448
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Apr 02 10:13:03 2021 +0000
description:
lint: name memory allocation functions consistently
No functional change.
diffstat:
usr.bin/xlint/lint1/cgram.y | 6 +-
usr.bin/xlint/lint1/decl.c | 18 ++++----
usr.bin/xlint/lint1/externs1.h | 16 +++---
usr.bin/xlint/lint1/func.c | 16 +++---
usr.bin/xlint/lint1/init.c | 10 ++--
usr.bin/xlint/lint1/mem1.c | 27 ++++++-----
usr.bin/xlint/lint1/tree.c | 93 +++++++++++++++++++++--------------------
7 files changed, 95 insertions(+), 91 deletions(-)
diffs (truncated from 665 to 300 lines):
diff -r 951c05786e44 -r a7c713d93448 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Fri Apr 02 10:06:26 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Fri Apr 02 10:13:03 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.208 2021/04/02 09:52:36 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.209 2021/04/02 10:13:03 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.208 2021/04/02 09:52:36 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.209 2021/04/02 10:13:03 rillig Exp $");
#endif
#include <limits.h>
@@ -1878,7 +1878,7 @@
$$ = new_string_node($1);
}
| T_CON {
- $$ = new_constant_node(gettyp($1->v_tspec), $1);
+ $$ = expr_new_constant(gettyp($1->v_tspec), $1);
}
| T_LPAREN expr T_RPAREN {
if ($2 != NULL)
diff -r 951c05786e44 -r a7c713d93448 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Fri Apr 02 10:06:26 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Fri Apr 02 10:13:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.167 2021/03/30 14:25:28 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.168 2021/04/02 10:13:03 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.167 2021/03/30 14:25:28 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.168 2021/04/02 10:13:03 rillig Exp $");
#endif
#include <sys/param.h>
@@ -162,7 +162,7 @@
{
type_t *ntp;
- ntp = tgetblk(sizeof *ntp);
+ ntp = expr_zalloc(sizeof *ntp);
*ntp = *tp;
return ntp;
}
@@ -1015,9 +1015,9 @@
/* function returns illegal type */
error(15);
if (t == FUNC) {
- *tpp = incref(*tpp, PTR);
+ *tpp = derive_type(*tpp, PTR);
} else {
- *tpp = incref((*tpp)->t_subt, PTR);
+ *tpp = derive_type((*tpp)->t_subt, PTR);
}
return;
} else if (tp->t_const || tp->t_volatile) {
@@ -1183,7 +1183,7 @@
} else if (t == FUNC) {
/* function illegal in structure or union */
error(38);
- dsym->s_type = tp = incref(tp, t = PTR);
+ dsym->s_type = tp = derive_type(tp, t = PTR);
}
/*
@@ -2416,12 +2416,12 @@
}
if ((t = sym->s_type->t_tspec) == ARRAY) {
- sym->s_type = incref(sym->s_type->t_subt, PTR);
+ sym->s_type = derive_type(sym->s_type->t_subt, PTR);
} else if (t == FUNC) {
if (tflag)
/* a function is declared as an argument: %s */
warning(50, sym->s_name);
- sym->s_type = incref(sym->s_type, PTR);
+ sym->s_type = derive_type(sym->s_type, PTR);
} else if (t == FLOAT) {
if (tflag)
sym->s_type = gettyp(DOUBLE);
@@ -3334,7 +3334,7 @@
* will be used later to match types.
*/
if (tn->tn_op != CON && dcs->d_ctx != ABSTRACT)
- tfreeblk();
+ expr_free_all();
if ((t = v->v_tspec) == FLOAT || t == DOUBLE || t == LDOUBLE) {
i = (int)v->v_ldbl;
diff -r 951c05786e44 -r a7c713d93448 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Fri Apr 02 10:06:26 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Fri Apr 02 10:13:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.97 2021/04/02 09:52:36 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.98 2021/04/02 10:13:03 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -105,11 +105,11 @@
extern void freeblk(void);
extern void freelblk(int);
-extern void *tgetblk(size_t);
+extern void *expr_zalloc(size_t);
extern tnode_t *expr_zalloc_tnode(void);
-extern void tfreeblk(void);
-extern struct memory_block *tsave(void);
-extern void trestor(struct memory_block *);
+extern void expr_free_all(void);
+extern struct memory_block *expr_save_memory(void);
+extern void expr_restore_memory(struct memory_block *);
/*
* err.c
@@ -196,9 +196,9 @@
/*
* tree.c
*/
-extern type_t *incref(type_t *, tspec_t);
-extern type_t *tincref(type_t *, tspec_t);
-extern tnode_t *new_constant_node(type_t *, val_t *);
+extern type_t *derive_type(type_t *, tspec_t);
+extern type_t *expr_derive_type(type_t *, tspec_t);
+extern tnode_t *expr_new_constant(type_t *, val_t *);
extern tnode_t *new_name_node(sym_t *, int);
extern tnode_t *new_string_node(strg_t *);
extern sym_t *struct_or_union_member(tnode_t *, op_t, sym_t *);
diff -r 951c05786e44 -r a7c713d93448 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Fri Apr 02 10:06:26 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Fri Apr 02 10:13:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.98 2021/03/26 20:31:07 rillig Exp $ */
+/* $NetBSD: func.c,v 1.99 2021/04/02 10:13:03 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.98 2021/03/26 20:31:07 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.99 2021/04/02 10:13:03 rillig Exp $");
#endif
#include <stdlib.h>
@@ -541,7 +541,7 @@
check_case_label(tn, ci);
- tfreeblk();
+ expr_free_all();
set_reached(true);
}
@@ -883,7 +883,7 @@
* Also remember this expression itself. We must check it at
* the end of the loop to get "used but not set" warnings correct.
*/
- cstmt->c_for_expr3_mem = tsave();
+ cstmt->c_for_expr3_mem = expr_save_memory();
cstmt->c_for_expr3 = tn3;
cstmt->c_for_expr3_pos = curr_pos;
cstmt->c_for_expr3_csrc_pos = csrc_pos;
@@ -920,7 +920,7 @@
cspos = csrc_pos;
/* Restore the tree memory for the reinitialization expression */
- trestor(cstmt->c_for_expr3_mem);
+ expr_restore_memory(cstmt->c_for_expr3_mem);
tn3 = cstmt->c_for_expr3;
curr_pos = cstmt->c_for_expr3_pos;
csrc_pos = cstmt->c_for_expr3_csrc_pos;
@@ -935,7 +935,7 @@
if (tn3 != NULL) {
expr(tn3, false, false, true, false);
} else {
- tfreeblk();
+ expr_free_all();
}
curr_pos = cpos;
@@ -1034,7 +1034,7 @@
if (tn != NULL && funcsym->s_type->t_subt->t_tspec == VOID) {
/* void function %s cannot return value */
error(213, funcsym->s_name);
- tfreeblk();
+ expr_free_all();
tn = NULL;
} else if (tn == NULL && funcsym->s_type->t_subt->t_tspec != VOID) {
/*
@@ -1049,7 +1049,7 @@
if (tn != NULL) {
/* Create a temporary node for the left side */
- ln = tgetblk(sizeof *ln);
+ ln = expr_zalloc(sizeof *ln);
ln->tn_op = NAME;
ln->tn_type = tduptyp(funcsym->s_type->t_subt);
ln->tn_type->t_const = false;
diff -r 951c05786e44 -r a7c713d93448 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Fri Apr 02 10:06:26 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Fri Apr 02 10:13:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.187 2021/04/02 09:39:25 rillig Exp $ */
+/* $NetBSD: init.c,v 1.188 2021/04/02 10:13:03 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.187 2021/04/02 09:39:25 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.188 2021/04/02 10:13:03 rillig Exp $");
#endif
#include <stdlib.h>
@@ -383,7 +383,7 @@
struct memory_block *tmem;
/* Create a temporary node for the left side. */
- ln = tgetblk(sizeof *ln);
+ ln = expr_zalloc(sizeof *ln);
ln->tn_op = NAME;
ln->tn_type = tduptyp(tp);
ln->tn_type->t_const = false;
@@ -404,9 +404,9 @@
* Preserve the tree memory. This is necessary because otherwise
* expr() would free it.
*/
- tmem = tsave();
+ tmem = expr_save_memory();
expr(tn, true, false, true, false);
- trestor(tmem);
+ expr_restore_memory(tmem);
check_bit_field_init(ln, lt, rt);
diff -r 951c05786e44 -r a7c713d93448 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c Fri Apr 02 10:06:26 2021 +0000
+++ b/usr.bin/xlint/lint1/mem1.c Fri Apr 02 10:13:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.40 2021/04/02 09:52:36 rillig Exp $ */
+/* $NetBSD: mem1.c,v 1.41 2021/04/02 10:13:03 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.40 2021/04/02 09:52:36 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.41 2021/04/02 10:13:03 rillig Exp $");
#endif
#include <sys/types.h>
@@ -336,24 +336,27 @@
* expression.
*/
void *
-tgetblk(size_t s)
+expr_zalloc(size_t s)
{
return xgetblk(&tmblk, s);
}
-/* Return a freshly allocated tree node. */
+/*
+ * Return a freshly allocated tree node that is freed at the end of the
+ * current expression.
+ */
tnode_t *
expr_zalloc_tnode(void)
{
- tnode_t *tn = tgetblk(sizeof *tn);
+ tnode_t *tn = expr_zalloc(sizeof *tn);
tn->tn_from_system_header = in_system_header;
return tn;
}
/* Free all memory which is allocated by the current expression. */
void
-tfreeblk(void)
+expr_free_all(void)
{
xfreeblk(&tmblk);
@@ -361,11 +364,11 @@
Home |
Main Index |
Thread Index |
Old Index