aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc
Commit message (Collapse)AuthorAgeFilesLines
* Remove MemoryRegion::set entirelylloyd2010-11-021-20/+34
|
* Make MemoryRegion::set protected, change all callerslloyd2010-10-291-8/+10
|
* s/u32bit/size_t/ in alloclloyd2010-10-128-79/+91
| | | | Also handle partial writes in alloc_mmap
* Use a full write instead of seek+write to create a sparselloyd2010-10-121-9/+7
| | | | | file. FreeBSD's man page for mmap warns that using NOSYNC with sparse files causes problems. Closes PR 30
* Fix, wasn't returning pointerlloyd2010-09-261-0/+1
|
* Malloc_Allocator isn't a pool, so it needs to fail directly if malloclloyd2010-09-261-1/+3
| | | | | fails, not just return 0 since callers expect that the allocator will either succeed or throw.
* Use push_back for the single value += operatorlloyd2010-09-151-3/+1
|
* Remove all versions of MemoryRegion::append.lloyd2010-09-151-19/+43
| | | | | | | Add a push_back that takes a single argument ala std::vector For appending, provide some namespace level += operators - we can use this technique with either MemoryRegion or a std::vector.
* Completely remove the second parameter to SecureVector which specifieslloyd2010-09-141-13/+6
| | | | | | | | | | | | | | | | | | | | the initial/default length of the array, update all users to instead pass the value to the constructor. This is a old vestigal thing from a class (SecureBuffer) that used this compile-time constant in order to store the values in an array. However this was changed way back in 2002 to use the same allocator hooks as the rest of the containers, so the only advantage to using the length field was that the initial length was set and didn't have to be set in the constructor which was midly convenient. However this directly conflicts with the desire to be able to (eventually) use std::vector with a custom allocator, since of course vector doesn't support this. Fortunately almost all of the uses are in classes which have only a single constructor, so there is little to no duplication by instead initializing the size in the constructor.
* Split up definitions so it is easer to remove functions I want to remove.lloyd2010-09-131-19/+21
| | | | | | Avoid using using directives in MemoryVector and SecureVector to bring things into scope; it brings them into public scope even if they are protected which is not desirable. Instead disambiguate using this->func()
* Don't expose init (protected) with a using directivelloyd2010-09-131-8/+6
|
* Remove constructors of MemoryVector and SecureVector that took twolloyd2010-09-131-18/+0
| | | | MemoryRegions and concatenated them.
* More vector->pointer conversion removals.lloyd2010-09-131-0/+7
| | | | | | | | | | | Add RandomNumberGenerator::random_vec, which takes an length n and returns a new SecureVector with randomized contents of that size. This nicely covers most of the cases where randomize was being called on a vector, and is a little cleaner in the code as well, instead of vec.resize(length); rng.randomize(&vec[0], vec.size()); we just write vec = rng.random_vec(length);
* Anywhere where we use MemoryRegion::begin to get access to the raw pointerlloyd2010-09-131-26/+27
| | | | | representation (rather than in an interator context), instead use &buf[0], which works for both MemoryRegion and std::vector
* Use a true lexicographic ordering in MemoryRegion::operator<lloyd2010-09-091-8/+11
|
* Rename MemoryRegion::destroy to MemoryRegion::clear to match STLlloyd2010-09-081-1/+1
|
* Big, invasive but mostly automated change, with a further attempt atlloyd2010-09-071-20/+26
| | | | | | | | | | | | | | harmonising MemoryRegion with std::vector: The MemoryRegion::clear() function would zeroise the buffer, but keep the memory allocated and the size unchanged. This is very different from STL's clear(), which is basically the equivalent to what is called destroy() in MemoryRegion. So to be able to replace MemoryRegion with a std::vector, we have to rename destroy() to clear() and we have to expose the current functionality of clear() in some other way, since vector doesn't support this operation. Do so by adding a global function named zeroise() which takes a MemoryRegion which is zeroed. Remove clear() to ensure all callers are updated.
* Realization while thinking about the recently added truncate: in a STLlloyd2010-09-071-40/+10
| | | | | | | | | | | | | | | | | | container like vector, truncate is simply resize, but what MemoryRegion called resize will zap the entire contents, and then what was resize was called grow_to. This is really problematic in terms of the goal of replacing MemoryRegion with a vector with a custom allocator. In this checkin: - Remove MemoryRegion::grow_to and MemoryRegion::truncate - Change the semantics of MemoryRegion::resize to change the size while keeping any current contents intact (up to the new size), zero initializing any new values. Unrelated, just noticed the lack while I was in there, add a version of CryptoBox::decrypt taking a std::string for the input.
* Cast the first argument to msync, munmap, mlock, and munlock to char*lloyd2010-09-071-2/+2
| | | | | to fix compilation on Solaris. Everybody else, including POSIX.1, uses void* here, but as usual Solaris likes to be special.
* Add a simple function to MemoryRegion to truncate to a specified size.lloyd2010-09-031-0/+10
| | | | Required by the hex decoder.
* Clang fixlloyd2010-08-081-0/+1
|
* Fix constructorlloyd2010-07-091-1/+1
|
* Argh: SecureVector's constructor needs to behave differentlylloyd2010-07-071-2/+14
| | | | | | | | | | | | | | depending on if INITIAL_LEN is non-zero. Normal semantics are the vector will change size based on whatever it is constructed with, but that's bad in cases like SecureVector<byte, 4> val(buffer, 3); which in the past would be a 4 valued thing with 3 elements set and one zero trailing. (This construct showed up in base64 and possibly elsewhere). If INITIAL_LEN is set, use copy instead so the length does not change. C++0x cannot come soon enough.
* Doxygenlloyd2010-06-214-3/+21
|
* Doxygenlloyd2010-06-211-3/+31
|
* Replace "@return a blah" and "@return the blah" with just "@return blah"lloyd2010-06-161-10/+10
|
* More Doxygen fixeslloyd2010-06-154-8/+11
|
* Fix a few hundred Doxygen warningslloyd2010-06-151-2/+2
|
* Change how alloc_mmap's TemporaryFile class works. Don't exposelloyd2010-06-131-10/+17
| | | | | | | | | | | | | | | | | | | | | | the name at all; instead unlink it at the end of the constructor, so by the time it is fully constructed it is purely an anonymous file descriptor. mkstemp has a weird interface and returns the final name of the file in its template argument. This prevented us from using a std::string, since c_str's return is const (and we can't use &string[0], because that might not be NULL-terminated). This previously required doing nasty things like explicit new/delete and using strcpy (the strcpy was what got me started on looking at this; OpenBSD complains about it, so I was trying to figure out a good way to remove it). Instead, use the idea from http://www.gotw.ca/gotw/042.htm, and use a std::vector to hold the mkstemp argument/result. That works consistently everywhere, and we don't need to rely on strcpy, and don't have to worry about memory leaks either. Only minor nit is having to add an explicit NULL terminator as the std::string doesn't contain it.
* Add a couple of small patches from Thomas Capricelli <[email protected]>lloyd2010-05-211-8/+16
| | | | that enable botan to be built under the clang C++ compiler.
* Rename SecureVector::L param to INITIAL_LEN so as to be somewhat obvious as ↵lloyd2010-03-231-2/+3
| | | | to meaning
* Remove SecureBuffer, which is the fixed-size variant of SecureVector.lloyd2010-03-231-38/+2
| | | | | | | | | | | | | | Add a second template param to SecureVector which specifies the initial length. Change all callers to be SecureVector instead of SecureBuffer. This can go away in C++0x, once compilers implement N2712 ("Non-static data member initializers"), and we can just write code as SecureVector<byte> P{18}; instead
* Remove reference to no-longer existing function in docslloyd2010-03-221-6/+2
|
* Fix Doxygen comment for grow_tolloyd2010-03-221-4/+6
|
* Guard call to the allocator in deallocate() by checking if the alloclloyd2010-03-101-1/+1
| | | | | | | | | | | | | | | | | | pointer was actually set. Otherwise, the following problem could occur if an allocator could not be found: init() will call Allocator::get, which throws an exception init() is called from the constructor of the subclasses (MemoryVector, etc) Since the constructor of MemoryRegion has already finished, its destructor will be called. ~MemoryRegion will call deallocate() deallocate() will then access a NULL pointer By guarding the call, the exception is propagated correctly.
* Clean up exceptions. Remove some unused ones like Config_Error. Makelloyd2010-01-052-14/+1
| | | | | | | Invalid_Argument just a typedef for std::invalid_argument. Make Botan::Exception a typedef for std::runtime_error. Make Memory_Exhaustion a public exception, and use it in other places where memory allocations can fail.
* Make many more headers internal-only.lloyd2009-12-169-15/+39
| | | | | | | | | | | | | Fixes for the amalgamation generator for internal headers. Remove BOTAN_DLL exporting macros from all internal-only headers; the classes/functions there don't need to be exported, and avoiding the PIC/GOT indirection can be a big win. Add missing BOTAN_DLLs where necessary, mostly gfpmath and cvc For GCC, use -fvisibility=hidden and set BOTAN_DLL to the visibility __attribute__ to export those classes/functions.
* Full working amalgamation build, plus internal-only headers concept.lloyd2009-12-163-18/+2
|
* Move most code that relies heavily on Filters into src/filters.lloyd2009-11-171-6/+0
| | | | | | Remove support for (unused) modset settings. Move tss, fpe, cryptobox, and aont to new dir constructs
* Rename/remove some secmem member variables for better matching with STLlloyd2009-11-171-22/+15
| | | | | | | | containers (specifically vector). Rename is_empty to empty Remove has_items Rename create to resize
* Remove some Doxygen commentslloyd2009-11-171-8/+2
|
* Remove the 'realname' attribute on all modules and cc/cpu/os info files.lloyd2009-10-294-8/+0
| | | | | Pretty much useless and unused, except for listing the module names in build.h and the short versions totally suffice for that.
* Remove all exception specifications. The way these are designed in C++ islloyd2009-10-222-6/+6
| | | | | | just too fragile and not that useful. Something like Java's checked exceptions might be nice, but simply killing the process entirely if an unexpected exception is thrown is not exactly useful for something trying to be robust.
* Split up util.h into 3 fileslloyd2009-09-171-1/+1
| | | | | | | - rounding.h (round_up, round_down) - workfactor.h (dl_work_factor) - timer.h (system_time) And update all users of the previous util.h
* Move memory locking function decls to mlock.hlloyd2009-09-171-1/+1
| | | | Inline round_up and round_down
* Add support for Dragonfly BSD (a fork of FreeBSD).lloyd2009-07-251-0/+1
| | | | Contributed by Patrick Georgi
* Move some files around to break up dependencies between directorieslloyd2009-07-162-0/+439
|
* Add a script that reads the output of print_deps.py and rewriteslloyd2009-07-153-8/+13
| | | | | | the info.txt files with the right module dependencies. Apply it across the codebase.
* Thomas Moschny passed along a request from the Fedora packagers which camelloyd2009-03-307-111/+125
| | | | | | | | | | | | | | | up during the Fedora submission review, that each source file include some text about the license. One handy Perl script later and each file now has the line Distributed under the terms of the Botan license after the copyright notices. While I was in there modifying every file anyway, I also stripped out the remainder of the block comments (lots of astericks before and after the text); this is stylistic thing I picked up when I was first learning C++ but in retrospect it is not a good style as the structure makes it harder to modify comments (with the result that comments become fewer, shorter and are less likely to be updated, which are not good things).
* Check the return value of lseek in the mmap allocatorlloyd2009-03-271-1/+3
|