Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 38179 invoked by uid 500); 7 Jun 2001 14:55:56 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 37840 invoked by uid 1103); 7 Jun 2001 14:55:50 -0000 Date: 7 Jun 2001 14:55:50 -0000 Message-ID: <20010607145550.37839.qmail@apache.org> From: dreid@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/shmem/beos shmem.c dreid 01/06/07 07:55:48 Modified: shmem/beos shmem.c Log: Make some of the checks clearer and remove the debugging stuff that is no longer needed. Submitted by: Greg Stein Reviewed by: David Reid Revision Changes Path 1.3 +6 -39 apr/shmem/beos/shmem.c Index: shmem.c =================================================================== RCS file: /home/cvs/apr/shmem/beos/shmem.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- shmem.c 2001/06/06 21:52:42 1.2 +++ shmem.c 2001/06/07 14:55:43 1.3 @@ -81,31 +81,10 @@ #define MIN_BLK_SIZE 128 -/* -#define DEBUG_ 1 -*/ void add_block(struct block_t **list, struct block_t *blk); void split_block(struct block_t **list, struct block_t *blk, apr_size_t size); -/* Debugging functions */ -#if DEBUG_ -static void printf_block(struct block_t *b) -{ - printf ("Block : %ld bytes\n\tthis = %x\n\tnext = %x\n", - b->size, b, b->nxt); -} - -static void walk_list(struct block_t *list) -{ - struct block_t *b = list; - do { - printf_block(b); - } - while ((b = b->nxt) != NULL); -} -#endif - static struct block_t * find_block_by_addr(struct block_t *list, void *addr) { struct block_t *b = list; @@ -140,18 +119,8 @@ } while ((b = b->nxt) != list); - if (diff > MIN_BLK_SIZE){ - split_block(&list, rv, size); - - /* we're going to split the block now... */ -/* apr_size_t nsz = rv->size - size; - struct block_t *blk = (struct block_t*)apr_pcalloc(rv->p, sizeof(struct block_t)); - blk->p = rv->p; - blk->size = nsz; - rv->size = size; - blk->addr = rv->addr + size; - add_block(&list, blk); -*/ + if (diff > MIN_BLK_SIZE) { + split_block(&list, rv, size); } if (rv) @@ -207,7 +176,7 @@ static void free_block(struct shmem_t *m, void *entity) { struct block_t *b; - if ((b = find_block_by_addr(m->uselist, entity))){ + if ((b = find_block_by_addr(m->uselist, entity)) != NULL){ remove_block(&(m->uselist), b); add_block(&(m->freelist), b); m->avail += b->size; @@ -221,7 +190,7 @@ if (m->avail < size) return NULL; - if ((b = find_block_of_size(m->freelist, size))){ + if ((b = find_block_of_size(m->freelist, size)) != NULL){ remove_block(&(m->freelist), b); } else { b = (struct block_t*)apr_pcalloc(m->p, sizeof(struct block_t)); @@ -263,8 +232,6 @@ return APR_SUCCESS; } - - apr_status_t apr_shm_destroy(struct shmem_t *m) { delete_area(m->aid); @@ -278,7 +245,7 @@ void *apr_shm_malloc(struct shmem_t *m, apr_size_t reqsize) { struct block_t *b; - if ((b = alloc_block(m, reqsize))) + if ((b = alloc_block(m, reqsize)) != NULL) return b->addr; return NULL; } @@ -286,7 +253,7 @@ void *apr_shm_calloc(struct shmem_t *m, apr_size_t reqsize) { struct block_t *b; - if ((b = alloc_block(m, reqsize))){ + if ((b = alloc_block(m, reqsize)) != NULL){ memset(b->addr, 0, reqsize); return b->addr; }