MEMB(cmem, 20, 8); int main(int argc, char *argv[]) { char *ptr; memb_init(&cmem); ptr = memb_alloc(&cmem); if(ptr != NULL) { do_something(ptr); } else { printf("Could not allocate memory.\n"); } if(memb_free(ptr) == 0) { printf("Deallocation succeeded.\n"); } }
#include <string.h>
#include "memb.h"
Include dependency graph for memb.c:
Functions | |
void | memb_init (struct memb_blocks *m) |
Initialize a memory block that was declared with MEMB(). | |
char * | memb_alloc (struct memb_blocks *m) |
Allocate a memory block from a block of memory declared with MEMB(). | |
char | memb_free (struct memb_blocks *m, char *ptr) |
Deallocate a memory block from a memory block previously declared with MEMB(). | |
char | memb_ref (struct memb_blocks *m, char *ptr) |
Increase the reference count for a memory chunk. |