Changeset 30 for trunk

Show
Ignore:
Timestamp:
12/04/06 18:19:12 (2 years ago)
Author:
scott
Message:

Added Properties.js

Location:
trunk
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/libapool/apool.c

    r28 r30  
    1111 
    1212    char *ram = chunk->chunk = calloc(blocks, blocksize); 
     13    void *stack = pool->stack; 
    1314 
    14     /* Stack must be able to hold atleast all available items */ 
    15     free(pool->stack); 
    1615    pool->blocks += blocks; 
    1716    pool->stack = calloc(pool->blocks, sizeof(void *)); 
     17 
     18    /* Copy from the old stack to the new stack pool->pos bytes */ 
     19    apool_copy(pool->stack, stack, pool->pos); 
     20    free(stack); 
    1821 
    1922    /* Use the ram in reverse order */ 
  • trunk/libapool/apool.h

    r29 r30  
    1616#define apool_double(pool) apool_expand(pool, pool->blocks) 
    1717#define apool_empty(pool) (pool->pos == 0) 
     18/* Duff's device copy...this is more optimized than while (*to++ = *from++) 
     19 * It determines an offset for the total copy, jumps to the offset for the 
     20 * first iteration and then continues to copy 8 bytes at a time until the end 
     21 * of len is met. 
     22 */ 
     23#define apool_copy(dest, src, len)                                          \ 
     24    char *to = dest;                                                        \ 
     25    register int n = (len + 7) / 8;                                         \ 
     26    switch (len % 8) {                                                      \ 
     27        case 0:                                                             \ 
     28            do {        *to++ = *from++;                                    \ 
     29                case 7: *to++ = *from++;                                    \ 
     30                case 6: *to++ = *from++;                                    \ 
     31                case 5: *to++ = *from++;                                    \ 
     32                case 4: *to++ = *from++;                                    \ 
     33                case 3: *to++ = *from++;                                    \ 
     34                case 2: *to++ = *from++;                                    \ 
     35                case 1: *to++ = *from++;                                    \ 
     36            } while (--n > 0);                                              \ 
     37    } 
    1838 
    1939extern apool * apool_new (size_t blocks, size_t blocksize);