Changed name of the internal struct memb_blocks to struct memb for consistency

This commit is contained in:
adamdunkels 2009-04-06 21:18:03 +00:00
parent 01d39d4149
commit d298fcbbd0
2 changed files with 12 additions and 12 deletions

View file

@ -30,7 +30,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
* $Id: memb.c,v 1.3 2007/03/16 16:53:33 adamdunkels Exp $ * $Id: memb.c,v 1.4 2009/04/06 21:18:03 adamdunkels Exp $
*/ */
/** /**
@ -50,14 +50,14 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
memb_init(struct memb_blocks *m) memb_init(struct memb *m)
{ {
memset(m->count, 0, m->num); memset(m->count, 0, m->num);
memset(m->mem, 0, m->size * m->num); memset(m->mem, 0, m->size * m->num);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void * void *
memb_alloc(struct memb_blocks *m) memb_alloc(struct memb *m)
{ {
int i; int i;
@ -77,7 +77,7 @@ memb_alloc(struct memb_blocks *m)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
char char
memb_free(struct memb_blocks *m, void *ptr) memb_free(struct memb *m, void *ptr)
{ {
int i; int i;
char *ptr2; char *ptr2;
@ -102,7 +102,7 @@ memb_free(struct memb_blocks *m, void *ptr)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
memb_inmemb(struct memb_blocks *m, void *ptr) memb_inmemb(struct memb *m, void *ptr)
{ {
return (char *)ptr >= (char *)m->mem && return (char *)ptr >= (char *)m->mem &&
(char *)ptr < (char *)m->mem + (m->num * m->size); (char *)ptr < (char *)m->mem + (m->num * m->size);

View file

@ -30,7 +30,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
* $Id: memb.h,v 1.5 2008/10/15 14:17:28 nvt-se Exp $ * $Id: memb.h,v 1.6 2009/04/06 21:18:04 adamdunkels Exp $
*/ */
/** /**
@ -90,11 +90,11 @@ MEMB(connections, struct connection, 16);
#define MEMB(name, structure, num) \ #define MEMB(name, structure, num) \
static char CC_CONCAT(name,_memb_count)[num]; \ static char CC_CONCAT(name,_memb_count)[num]; \
static structure CC_CONCAT(name,_memb_mem)[num]; \ static structure CC_CONCAT(name,_memb_mem)[num]; \
static struct memb_blocks name = {sizeof(structure), num, \ static struct memb name = {sizeof(structure), num, \
CC_CONCAT(name,_memb_count), \ CC_CONCAT(name,_memb_count), \
(void *)CC_CONCAT(name,_memb_mem)} (void *)CC_CONCAT(name,_memb_mem)}
struct memb_blocks { struct memb {
unsigned short size; unsigned short size;
unsigned short num; unsigned short num;
char *count; char *count;
@ -106,14 +106,14 @@ struct memb_blocks {
* *
* \param m A memory block previously declared with MEMB(). * \param m A memory block previously declared with MEMB().
*/ */
void memb_init(struct memb_blocks *m); void memb_init(struct memb *m);
/** /**
* Allocate a memory block from a block of memory declared with MEMB(). * Allocate a memory block from a block of memory declared with MEMB().
* *
* \param m A memory block previously declared with MEMB(). * \param m A memory block previously declared with MEMB().
*/ */
void *memb_alloc(struct memb_blocks *m); void *memb_alloc(struct memb *m);
/** /**
* Deallocate a memory block from a memory block previously declared * Deallocate a memory block from a memory block previously declared
@ -127,9 +127,9 @@ void *memb_alloc(struct memb_blocks *m);
* if successfully deallocated) or -1 if the pointer "ptr" did not * if successfully deallocated) or -1 if the pointer "ptr" did not
* point to a legal memory block. * point to a legal memory block.
*/ */
char memb_free(struct memb_blocks *m, void *ptr); char memb_free(struct memb *m, void *ptr);
int memb_inmemb(struct memb_blocks *m, void *ptr); int memb_inmemb(struct memb *m, void *ptr);
/** @} */ /** @} */