- Sep 08, 2019
-
-
Simon Tatham authored
The number of people has been steadily increasing who read our source code with an editor that thinks tab stops are 4 spaces apart, as opposed to the traditional tty-derived 8 that the PuTTY code expects. So I've been wondering for ages about just fixing it, and switching to a spaces-only policy throughout the code. And I recently found out about 'git blame -w', which should make this change not too disruptive for the purposes of source-control archaeology; so perhaps now is the time. While I'm at it, I've also taken the opportunity to remove all the trailing spaces from source lines (on the basis that git dislikes them, and is the only thing that seems to have a strong opinion one way or the other). Apologies to anyone downstream of this code who has complicated patch sets to rebase past this change. I don't intend it to be needed again.
-
- Jul 10, 2019
-
-
Simon Tatham authored
We were carefully checking for overflow inside safemalloc() before multiplying together the two factors of the desired allocation size. But snew_plus() did an addition _outside_ safemalloc, without the same guard. Now that addition also happens inside safemalloc.
-
- Mar 02, 2019
-
-
Simon Tatham authored
These versions, distinguished by the _nm suffix on their names, avoid using realloc to grow the array, in case it moves the block and leaves a copy of the data in the freed memory at the old address. (The suffix 'nm' stands for 'no moving'.) Instead, the array is grown by making a new allocation, manually copying the data over, and carefully clearing the old block before freeing it. (An alternative would be to give this code base its own custom heap in which the ordinary realloc takes care about this kind of thing, but I don't really feel like going to that much effort!)
-
- Feb 28, 2019
-
-
Simon Tatham authored
The idea of these is that they centralise the common idiom along the lines of if (logical_array_len >= physical_array_size) { physical_array_size = logical_array_len * 5 / 4 + 256; array = sresize(array, physical_array_size, ElementType); } which happens at a zillion call sites throughout this code base, with different random choices of the geometric factor and additive constant, sometimes forgetting them completely, and generally doing a lot of repeated work. The new macro sgrowarray(array,size,n) has the semantics: here are the array pointer and its physical size for you to modify, now please ensure that the nth element exists, so I can write into it. And sgrowarrayn(array,size,n,m) is the same except that it ensures that the array has size at least n+m (so sgrowarray is just the special case where m=1). Now that this is a single centralised implementation that will be used everywhere, I've also gone to more effort in the implementation, with careful overflow checks that would have been painful to put at all the previous call sites. This commit also switches over every use of sresize(), apart from a few where I really didn't think it would gain anything. A consequence of that is that a lot of array-size variables have to have their types changed to size_t, because the macros require that (they address-take the size to pass to the underlying function).
-
Simon Tatham authored
I haven't tried compiling with /DMINEFIELD in a while, and when I just did, I found that the declarations in winstuff.h weren't actually being included by memory.c where they're needed.
-
- Jan 03, 2019
-
-
Simon Tatham authored
Now that that facility is centralised in defs.h, there's no reason to have a special ad-hoc version in sresize and separately comment it.
-
Simon Tatham authored
misc.c has always contained a combination of things that are tied tightly into the PuTTY code base (e.g. they use the conf system, or work with our sockets abstraction) and things that are pure standalone utility functions like nullstrcmp() which could quite happily be dropped into any C program without causing a link failure. Now the latter kind of standalone utility code lives in the new source file utils.c, whose only external dependency is on memory.c (for snew, sfree etc), which in turn requires the user to provide an out_of_memory() function. So it should now be much easier to link test programs that use PuTTY's low-level functions without also pulling in half its bulky infrastructure. In the process, I came across a memory allocation logging system enabled by -DMALLOC_LOG that looks long since bit-rotted; in any case we have much more advanced tools for that kind of thing these days, like valgrind and Leak Sanitiser, so I've just removed it rather than trying to transplant it somewhere sensible. (We can always pull it back out of the version control history if really necessary, but I haven't used it in at least a decade.) The other slightly silly thing I did was to give bufchain a function pointer field that points to queue_idempotent_callback(), and disallow direct setting of the 'ic' field in favour of calling bufchain_set_callback which will fill that pointer in too. That allows the bufchain system to live in utils.c rather than misc.c, so that programs can use it without also having to link in the callback system or provide an annoying stub of that function. In fact that's just allowed me to remove stubs of that kind from PuTTYgen and Pageant!
-
- Jun 06, 2018
-
-
Simon Tatham authored
This formalises my occasional habit of using a single malloc to make a block that contains a header structure and a data buffer that a field of the structure will point to, allowing it to be freed in one go later. Previously I had to do this by hand, losing the type-checking advantages of snew; now I've written an snew-style macro to do the job, plus an accessor macro to cleanly get the auxiliary buffer pointer afterwards, and switched existing instances of the pattern over to using that.
-
- Jul 19, 2012
-
-
Simon Tatham authored
compile warning ('left-hand operand of comma expression has no effect'), which of course becomes fatal under -Werror. (This would have been instantly noticeable to people compiling with the old-fashioned Makefile.gtk, which does include -Wall -Werror, but those of us using the new autoconf makefile hadn't noticed.) [originally from svn r9582]
-
- May 18, 2012
-
-
Simon Tatham authored
_in_ to it, as well as the one it returns. Why have I never thought of doing that before?! [originally from svn r9539]
-
- Jul 06, 2005
-
-
Jacob Nevins authored
[originally from svn r6075]
-
- Feb 20, 2005
-
-
Simon Tatham authored
[originally from svn r5358]
-
- Mar 29, 2003
-
-
Simon Tatham authored
malloc functions, which automatically cast to the same type they're allocating the size of. Should prevent any future errors involving mallocing the size of the wrong structure type, and will also make life easier if we ever need to turn the PuTTY core code from real C into C++-friendly C. I haven't touched the Mac frontend in this checkin because I couldn't compile or test it. [originally from svn r3014]
-
- May 06, 2001
-
-
Simon Tatham authored
coding styles of the various contributors! Woohoo! [originally from svn r1098]
-
- Apr 28, 2001
-
-
Simon Tatham authored
[originally from svn r1079]
-
- Dec 12, 2000
-
-
Simon Tatham authored
smalloc() macros and thence to the safemalloc() functions in misc.c. This should allow me to plug in a debugging allocator and track memory leaks and segfaults and things. [originally from svn r818]
-