diff options
author | Eli Bendersky <eliben@gmail.com> | 2018-02-06 19:46:48 -0800 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2018-02-06 19:46:48 -0800 |
commit | 4992410bf8c2d6d7eb94703d0f6f94b5a9acaa0a (patch) | |
tree | c7b5ca69cafb43f344c56b7ae495385cdd1ceab4 /examples | |
parent | 1894fd79f7235c4af6d1eb46768451d02ed4a867 (diff) | |
download | pycparser-4992410bf8c2d6d7eb94703d0f6f94b5a9acaa0a.tar.gz |
Remove trailing whitespace from .h/.c files
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c_files/memmgr.c | 22 | ||||
-rw-r--r-- | examples/c_files/memmgr.h | 38 |
2 files changed, 30 insertions, 30 deletions
diff --git a/examples/c_files/memmgr.c b/examples/c_files/memmgr.c index 41a62c0..d9bc290 100644 --- a/examples/c_files/memmgr.c +++ b/examples/c_files/memmgr.c @@ -2,7 +2,7 @@ // Statically-allocated memory manager // // by Eli Bendersky (eliben@gmail.com) -// +// // This code is in the public domain. //---------------------------------------------------------------- #include "memmgr.h" @@ -11,7 +11,7 @@ typedef ulong Align; union mem_header_union { - struct + struct { // Pointer to the next block in the free list // @@ -19,7 +19,7 @@ union mem_header_union // Size of the block (in quantas of sizeof(mem_header_t)) // - ulong size; + ulong size; } s; // Used to align headers in memory to a boundary @@ -80,9 +80,9 @@ static mem_header_t* get_mem_from_pool(ulong nquantas) // Allocations are done in 'quantas' of header size. -// The search for a free block of adequate size begins at the point 'freep' +// The search for a free block of adequate size begins at the point 'freep' // where the last block was found. -// If a too-big block is found, it is split and the tail is returned (this +// If a too-big block is found, it is split and the tail is returned (this // way the header of the original needs only to have its size adjusted). // The pointer returned to the user points to the free space within the block, // which begins one quanta after the header. @@ -100,7 +100,7 @@ void* memmgr_alloc(ulong nbytes) // First alloc call, and no free list yet ? Use 'base' for an initial // denegerate block of size 0, which points to itself - // + // if ((prevp = freep) == 0) { base.s.next = freep = prevp = &base; @@ -110,7 +110,7 @@ void* memmgr_alloc(ulong nbytes) for (p = prevp->s.next; ; prevp = p, p = p->s.next) { // big enough ? - if (p->s.size >= nquantas) + if (p->s.size >= nquantas) { // exactly ? if (p->s.size == nquantas) @@ -151,7 +151,7 @@ void* memmgr_alloc(ulong nbytes) } -// Scans the free list, starting at freep, looking the the place to insert the +// Scans the free list, starting at freep, looking the the place to insert the // free block. This is either between two existing blocks or at the end of the // list. In any case, if the block being freed is adjacent to either neighbor, // the adjacent blocks are combined. @@ -169,9 +169,9 @@ void memmgr_free(void* ap) // for (p = freep; !(block > p && block < p->s.next); p = p->s.next) { - // Since the free list is circular, there is one link where a - // higher-addressed block points to a lower-addressed block. - // This condition checks if the block should be actually + // Since the free list is circular, there is one link where a + // higher-addressed block points to a lower-addressed block. + // This condition checks if the block should be actually // inserted between them // if (p >= p->s.next && (block > p || block < p->s.next)) diff --git a/examples/c_files/memmgr.h b/examples/c_files/memmgr.h index 47ddadb..e792fb8 100644 --- a/examples/c_files/memmgr.h +++ b/examples/c_files/memmgr.h @@ -2,45 +2,45 @@ // Statically-allocated memory manager // // by Eli Bendersky (eliben@gmail.com) -// +// // This code is in the public domain. //---------------------------------------------------------------- #ifndef MEMMGR_H #define MEMMGR_H // -// Memory manager: dynamically allocates memory from +// Memory manager: dynamically allocates memory from // a fixed pool that is allocated statically at link-time. -// -// Usage: after calling memmgr_init() in your +// +// Usage: after calling memmgr_init() in your // initialization routine, just use memmgr_alloc() instead // of malloc() and memmgr_free() instead of free(). -// Naturally, you can use the preprocessor to define -// malloc() and free() as aliases to memmgr_alloc() and -// memmgr_free(). This way the manager will be a drop-in +// Naturally, you can use the preprocessor to define +// malloc() and free() as aliases to memmgr_alloc() and +// memmgr_free(). This way the manager will be a drop-in // replacement for the standard C library allocators, and can -// be useful for debugging memory allocation problems and +// be useful for debugging memory allocation problems and // leaks. // -// Preprocessor flags you can define to customize the +// Preprocessor flags you can define to customize the // memory manager: // // DEBUG_MEMMGR_FATAL // Allow printing out a message when allocations fail // // DEBUG_MEMMGR_SUPPORT_STATS -// Allow printing out of stats in function -// memmgr_print_stats When this is disabled, +// Allow printing out of stats in function +// memmgr_print_stats When this is disabled, // memmgr_print_stats does nothing. // -// Note that in production code on an embedded system +// Note that in production code on an embedded system // you'll probably want to keep those undefined, because // they cause printf to be called. // // POOL_SIZE -// Size of the pool for new allocations. This is -// effectively the heap size of the application, and can -// be changed in accordance with the available memory +// Size of the pool for new allocations. This is +// effectively the heap size of the application, and can +// be changed in accordance with the available memory // resources. // // MIN_POOL_ALLOC_QUANTAS @@ -49,19 +49,19 @@ // minimize pool fragmentation in case of multiple allocations // and deallocations, it is advisable to not allocate // blocks that are too small. -// This flag sets the minimal ammount of quantas for +// This flag sets the minimal ammount of quantas for // an allocation. If the size of a ulong is 4 and you // set this flag to 16, the minimal size of an allocation // will be 4 * 2 * 16 = 128 bytes // If you have a lot of small allocations, keep this value -// low to conserve memory. If you have mostly large -// allocations, it is best to make it higher, to avoid +// low to conserve memory. If you have mostly large +// allocations, it is best to make it higher, to avoid // fragmentation. // // Notes: // 1. This memory manager is *not thread safe*. Use it only // for single thread/task applications. -// +// #define DEBUG_MEMMGR_SUPPORT_STATS 1 |