/[pcre]/code/trunk/sljit/sljitExecAllocator.c
ViewVC logotype

Diff of /code/trunk/sljit/sljitExecAllocator.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 835 by ph10, Wed Dec 28 16:10:09 2011 UTC revision 836 by ph10, Wed Dec 28 17:16:11 2011 UTC
# Line 1  Line 1 
1  /*  /*
2   *    Stack-less Just-In-Time compiler   *    Stack-less Just-In-Time compiler
3   *   *
4   *    Copyright 2009-2010 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.   *    Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5   *   *
6   * Redistribution and use in source and binary forms, with or without modification, are   * Redistribution and use in source and binary forms, with or without modification, are
7   * permitted provided that the following conditions are met:   * permitted provided that the following conditions are met:
# Line 163  static SLJIT_INLINE void sljit_remove_fr Line 163  static SLJIT_INLINE void sljit_remove_fr
163          }          }
164  }  }
165    
166  void* sljit_malloc_exec(sljit_uw size)  SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
167  {  {
168          struct block_header *header;          struct block_header *header;
169          struct block_header *next_header;          struct block_header *next_header;
# Line 231  void* sljit_malloc_exec(sljit_uw size) Line 231  void* sljit_malloc_exec(sljit_uw size)
231          return MEM_START(header);          return MEM_START(header);
232  }  }
233    
234  void sljit_free_exec(void* ptr)  SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
235  {  {
236          struct block_header *header;          struct block_header *header;
237          struct free_block* free_block;          struct free_block* free_block;
# Line 263  void sljit_free_exec(void* ptr) Line 263  void sljit_free_exec(void* ptr)
263                  header->prev_size = free_block->size;                  header->prev_size = free_block->size;
264          }          }
265    
266            /* The whole chunk is free. */
267          if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) {          if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) {
268                    /* If this block is freed, we still have (allocated_size / 2) free space. */
269                  if (total_size - free_block->size > (allocated_size * 3 / 2)) {                  if (total_size - free_block->size > (allocated_size * 3 / 2)) {
270                            total_size -= free_block->size;
271                          sljit_remove_free_block(free_block);                          sljit_remove_free_block(free_block);
272                          free_chunk(free_block, free_block->size + sizeof(struct block_header));                          free_chunk(free_block, free_block->size + sizeof(struct block_header));
273                  }                  }

Legend:
Removed from v.835  
changed lines
  Added in v.836

  ViewVC Help
Powered by ViewVC 1.1.5