History log of /src/usr.bin/make/buf.c |
Revision | | Date | Author | Comments |
1.58 |
| 28-Apr-2024 |
rillig | make: don't reallocate memory after evaluating an expression
When an expression is evaluated, the resulting text is short-lived in almost all cases. In particular, the compaction neither affects the target names nor the global variable values, which are the prime candidates for permanent memory usage.
|
1.57 |
| 19-Dec-2023 |
rillig | make: clean up comments
No binary change, except for line numbers in assertions.
|
1.56 |
| 01-Jun-2023 |
rillig | make: shorten function names, clean up comments
No functional change.
|
1.55 |
| 08-Jan-2022 |
rillig | make: inline Buf_Clear
No functional change.
|
1.54 |
| 15-Dec-2021 |
rillig | make: prevent memory leaks from buffers
The warning about unused function results would have prevented the memory leak that was fixed in cond.c 1.303 from 2021-12-13.
|
1.53 |
| 28-Nov-2021 |
rillig | make: move duplicate function Buf_AddFlag to buf.c
It is used only for debug output, therefore performance doesn't matter.
No functional change.
|
1.52 |
| 21-Jun-2021 |
rillig | make: use simpler upper bound for length in Buf_AddInt
No functional change.
|
1.51 |
| 30-Jan-2021 |
rillig | make(1): remove __predict_false
The effect (at least on x86_64) is so minimal that it is not worth cluttering the code.
|
1.50 |
| 30-Jan-2021 |
rillig | make(1): inline Buf_GetAll
|
1.49 |
| 30-Jan-2021 |
rillig | make(1): only clean up the Buffer data in CLEANUP mode
Cleaning up the members is only useful during debugging but not during use in production.
|
1.48 |
| 30-Jan-2021 |
rillig | make(1): split Buf_Destroy into Buf_Done and Buf_DoneData
In all cases except one, the boolean argument to Buf_Destroy was constant. Removing that argument by splitting the function into two separate functions makes the intention clearer on the call site. It also removes the possibility for using the return value of Buf_Done, which would have made no sense.
The function Buf_Done now pairs with Buf_Init, just as in HashTable and Lst.
Even though Buf_Done is essentially a no-op, it is kept as a function, both for symmetry with Buf_Init and for clearing the Buffer members after use (this will be done only in CLEANUP mode, in a follow-up commit).
|
1.47 |
| 30-Dec-2020 |
rillig | make(1): format multi-line comments
|
1.46 |
| 28-Dec-2020 |
rillig | make(1): rename Buf_Expand_1 to Buf_Expand
|
1.45 |
| 23-Nov-2020 |
rillig | make(1): indent buf.c with tabs instead of spaces
|
1.44 |
| 07-Nov-2020 |
rillig | make(1): make API of Buf_Init simpler
In most cases, the caller doesn't want to specify the exact number of preallocated bytes.
|
1.43 |
| 07-Nov-2020 |
rillig | make(1): clean up code stylistically
* Replace character literal 0 with '\0'. * Replace pointer literal 0 with NULL. * Remove redundant parentheses. * Parentheses in multi-line conditions are not redundant at the beginning of a line. * Replace a few !ptr with ptr == NULL. * Replace a few ptr with ptr != NULL. * Replace (expr & mask) == 0 with !(expr & mask). * Remove redundant braces for blocks in cases where the generated code stays the same. (Assertions further down in the code would get different line numbers.) * Rename parameters in CondParser_String to reflect the data flow. * Replace #ifdef notdef with #if 0.
The generated code stays exactly the same, at least with GCC 5.5.0 on NetBSD 8.0 amd64 using the default configuration.
|
1.42 |
| 24-Oct-2020 |
rillig | make(1): remove macros MIN and MAX
These macros typically evaluate one of their arguments twice. Until 2020-08-31, they had not parenthesized their arguments properly. They are only used in a few places, therefore it doesn't hurt much to have them expanded.
|
1.41 |
| 24-Oct-2020 |
rillig | make(1): clean up comments in buf.c
|
1.40 |
| 27-Sep-2020 |
rillig | make(1): in the Buffer functions, rename bp to buf
It's not necessary to emphasize on the pointerness of the variable since that's obvious from the context.
|
1.39 |
| 27-Sep-2020 |
rillig | make(1): rename Buffer fields
It was confusing to have a function Buf_Size that returns buf->count even though there is also buf->size.
|
1.38 |
| 13-Sep-2020 |
rillig | make(1): clean up RCSID blocks
These blocks mostly consisted of redundant structure, following the same #ifndef pattern over and over, with only minimal variation.
It's easier to maintain if the common structure is only written once and encapsulated in a macro.
To avoid "defined but unused" warnings from GCC in the case where MAKE_NATIVE is not defined, I had to add volatile. Adding MAKE_ATTR_UNUSED alone would not preserve the rcsid variable in the resulting binary.
|
1.37 |
| 23-Aug-2020 |
rillig | make(1): clean up code in buf.c
|
1.36 |
| 23-Aug-2020 |
rillig | make(1): use common MAX macro instead of self-defined
|
1.35 |
| 13-Aug-2020 |
rillig | make(1): remove type alias Byte = char
This alias was only actually used in very few places, and changing it to unsigned char or any other type would not be possible without generating lots of compile-time errors. Therefore there was no abstraction, only unnecessary complexity.
|
1.34 |
| 09-Aug-2020 |
rillig | make(1): format the source code consistently, at least per file
Some files use 4 spaces per indentation level, others use 8. At least for the few files from this commit, they use a consistent style throughout each file now.
In Cond_Eval, the #define has changed into an enum since the identifiers need not be visible to the C preprocessor.
|
1.33 |
| 09-Aug-2020 |
rillig | make(1): fix variable length array in Buf_AddInt
GCC 5 complained about this, but only when make is build with both USE_COVERAGE=yes and USE_FORT=yes.
|
1.32 |
| 08-Aug-2020 |
rillig | make(1): remove trailing Z from buffer functions
This Z had been useful during the migration from int to size_t. This migration is finished, at least for the Buffer type, so the Z is no longer necessary.
|
1.31 |
| 03-Aug-2020 |
rillig | make(1): no declaration-after-statement anymore
NetBSD make is intended to be maximally portable, therefore it uses only C89. This was not declared in the Makefile before.
There are still a few places in parse.c and metachar.c that use end-of-line comments. These will be fixed in a follow-up commit.
|
1.30 |
| 01-Aug-2020 |
rillig | make(1): remove redundant if clause from Buf_DestroyCompact
bmake_realloc can never return NULL.
|
1.29 |
| 01-Aug-2020 |
rillig | make(1): switch Buffer size from int to size_t
This change helps to make the various integer types compatible and is a preparational step for setting WARNS=6 in the Makefile.
The documentation of buf.c has been cleaned up and condensed since it was mostly redundant, and some statements were even slightly wrong.
All code changes are covered by the existing unit tests, except for the few lines in for.c around for_var_len. These changes have been reviewed thoroughly and manually, like all the others in this commit.
Those buffer functions that deal with sizes have been renamed by appending a Z, to make sure that no function call was accidentally forgotten. They will be renamed back in a follow-up commit.
As usual, the scope of a few affected variables has been reduced, and some variables had to be split since they had been incorrectly merged before.
The order of the arguments to Buf_AddBytes has changed from (mem_len, mem) to (mem, mem_len), in order to make it consistent with the functions from the C standard library, such as snprintf.
|
1.28 |
| 26-Jul-2020 |
rillig | make(1): add Buffer functions for common tasks
Adding a string or a substring to a buffer are common tasks when handling variables. There is no need to spell out the strlen call or the pointer subtraction at every call site.
Subtracting pointers results in a ptrdiff_t, which would have to be converted to an int in each case for WARNS=6. Having this conversion in a single place keeps the code clean.
|
1.27 |
| 26-Jul-2020 |
rillig | make(1): add Buf_AddInt to make the calling code simpler
|
1.26 |
| 03-Jul-2020 |
rillig | make(1): remove redundant parentheses around return values
|
1.25 |
| 24-Apr-2012 |
sjg | Var* are generally very liberal with memory, with the expectation that none of it persists for long. This isn't always true - for example a long running .for loop.
Buf_DestroyCompact() is used by Var_Subst(), rather than Buf_Destroy(). If it looks like we can save BUF_COMPACT_LIMIT (128) or more bytes, call realloc. This can reduce memory consumption by about 20% Setting BUF_COMPACT_LIMIT to 0 dissables this.
|
1.24 |
| 17-Jan-2009 |
dsl | branches: 1.24.8; Change 'Buffer' so that it is the actual struct, not a pointer to it. Saves having to malloc/free a fixed size structure. Buf_Init() now takes ptr to Buffer to initialiase. Change Buf_Destroy() to return ptr to string when not freed. Remove large number of casts to (Byte) and (Byte *) - 'Byte' is 'char' here. Buf_AddByte[s] guarantees that the data is 0 termininated, so never add '\0'. Keep 'count' not 'left' and 'inPtr', code is simplier with only one update. Fix fallou, no functional change.
|
1.23 |
| 20-Dec-2008 |
dsl | A lot of code assumes that the pointer returned by Buf_GetAll() is malloced. Replace Buf_Discard() with Buf_Empty() since the former might leave the 'outPtr != buffer' and the only caller wanted all the data discared. Remove 'outPtr' now that it always equals 'buffer'. The assumption about Buf_GetAll()is now guaranteed by design.
|
1.22 |
| 06-Oct-2008 |
joerg | Don't use emalloc and friends directly, but call them consistently bmake_malloc and friends. Implement them via macros for the native case and provide fallback implementations otherwise. Avoid polluting the namespace by not defining enomem globally. Don't bother to provide strdup and strndup, they were only used for the estrdup and estrndup comapt code.
This addresses the presence of emalloc in system libraries on A/UX and resulted strange issues as reported by Timothy E. Larson.
|
1.21 |
| 15-Feb-2008 |
christos | back all changes out until I fix it properly.
|
1.20 |
| 14-Feb-2008 |
christos | - use pid_t/size_t as appropriate instead of int. - use %ld to print pids. - fix a bit of lint. - WARNS=4
|
1.19 |
| 08-Aug-2005 |
christos | From Max Okumoto: - Remove casts to NULL. - Remove space between cast and object.
|
1.18 |
| 05-Aug-2005 |
christos | More KNF cleanups from Max Okumoto
|
1.17 |
| 25-Jul-2005 |
christos | Whitespace KNF cleanup from Max Okumoto
|
1.16 |
| 16-Feb-2005 |
christos | PR/29203, PR/29204: Max Okumoto: KNF changes to make [no functional changes]
|
1.15 |
| 07-May-2004 |
ross | Simplify build, no functional changes.
Instead of adding MAKE_BOOTSTRAP for hosted environments, i.e., when you want things simple, instead add MAKE_NATIVE to get those hugely important features like __RCSID().
It's now possible to build make on some hosts with: cc *.c */*.c
|
1.14 |
| 07-Aug-2003 |
agc | branches: 1.14.2; Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
|
1.13 |
| 15-Jun-2002 |
wiz | Remove !__STDC__ stuff, de-__P(), ANSIfy, and de-register.
|
1.12 |
| 15-Sep-1999 |
mycroft | Nuke Buf_{G,Ung}etByte{,s}(), since they aren't used, and make BufExpand do power-of-2 allocation.
|
1.11 |
| 28-Sep-1997 |
lukem | wrap #include <sys/cdefs.h>, __RCSID(...) stuff in #ifndef MAKE_BOOTSTRAP
|
1.10 |
| 01-Jul-1997 |
christos | Add WARNS=1 RCSID police
|
1.9 |
| 31-Dec-1996 |
christos | Use only integral types in procedure arguments.
|
1.8 |
| 06-Nov-1996 |
christos | - Merge in FreeBSD and Lite2 changes. - Fix bug where a non-archive target with a .a suffix would always be considered to be out of date, since it does not have a TOC.
|
1.7 |
| 29-Mar-1996 |
jtc | branches: 1.7.4; Added erealloc() function that calls enomem() if the allocation fails (this is like the existing emalloc() function). Changed all realloc() calls to erealloc().
|
1.6 |
| 14-Jun-1995 |
christos | - $NetBSD$ rcsids - Fixed so that .[A-Z]* targets that do not match keywords are ignored as Posix mandates - Added .PHONY target keyword
|
1.5 |
| 06-Jun-1994 |
jtc | Fixes from Christos Zoulas, who used purify, objectcenter and testcenter to find memory leaks and illegal memory accesses.
|
1.4 |
| 05-Mar-1994 |
cgd | fixes/improvements from Christos Zoulas <christos@deshaw.com>.
|
1.3 |
| 13-Jan-1994 |
jtc | Include appropriate header files to bring prototypes into scope.
|
1.2 |
| 01-Aug-1993 |
mycroft | Add RCS identifiers.
|
1.1 |
| 21-Mar-1993 |
cgd | branches: 1.1.1; Initial revision
|
1.1.1.2 |
| 28-Dec-1996 |
tls | Import 4.4BSD-Lite2 sources onto CSRG branch (already merged at head)
|
1.1.1.1 |
| 21-Mar-1993 |
cgd | initial import of 386bsd-0.1 sources
|
1.7.4.1 |
| 26-Jan-1997 |
rat | Update make(1) from trunk, by request from Christos Zoulas. Fixes many bugs.
|
1.14.2.1 |
| 10-May-2004 |
tron | Pull up revision 1.15 (requested by sjg in ticket #282): Simplify build, no functional changes. Instead of adding MAKE_BOOTSTRAP for hosted environments, i.e., when you want things simple, instead add MAKE_NATIVE to get those hugely important features like __RCSID(). It's now possible to build make on some hosts with: cc *.c */*.c
|
1.24.8.1 |
| 23-May-2012 |
yamt | sync with head.
|