Source files: src/MemSys/pool.c
Header files: incl/MemSys/simsys.h
Many of the objects used in the event-driven simulation library and memory system simulator are allocated using the YACSIM pool functions, which seek to minimize the number of calls to malloc and free. Each structure in the pool must begin with the following two fields:
char *pnxt
char *pfnxt
These fields maintain the pool and the free list for the pool. The pool functions supported in RSIM are:
This function initializes the pool pointed to by pptr, setting the name of the pool to name and declaring that this pool will allocate structures of size objsz (this size includes the pnxt and pfnxt fields). Whenever the pool runs out of available objects, it will allocate objs structures of size objsz from the system memory allocator.
This function returns an object from the given pool. If this pool does not have any objects, it should allocate the number of objects specified on the original cool to YS__PoolInit.
This function also performs minimal initialization when allocating from the pool of memory system transactions.
This function returns the object pointed to by optr back to the pool pointed to by pptr, from which the object was allocated. Indeterminate results will occur if an object is returned to a different pool than the one from which it was allocated.
This function prints the number of objects allocated from and returned to a given pool. This function can be used to detect memory leaks in certain cases.
Users further interested in the YACSIM simulation library should consult the YACSIM reference manual [8].