| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflmem.h" DESCR * mem_descr_ ( MEMTRN *trn, /* Associated transaction */ const void *data_block, /* Block of memory to copy */ size_t data_size, /* Size of memory block */ const char *filename, /* Name of source file making call */ size_t lineno /* Line number in calling source */ )
Allocates a DESCR block for a specified block of data. Use the mem_descr macro to call this function! Returns a pointer to an allocated DESCR block, or NULL if there was not enough memory. The DESCR block is allocated as a single block, consisting of the DESCR block plus the data. To free the entire block you need one call to mem_free(). If the data_block argument is not null, its contents are copied into the newly allocated memory.
{ DESCR *descr; descr = mem alloc (trn, data_size + sizeof (DESCR), filename, lineno); if (descr == NULL) return (NULL); # if (defined (MEM_TRACE)) trace ("%s (%ld): allocate descr=%p", filename? filename: "-", (long) lineno, descr); # endif /* Fill-in descriptor block unless it is NULL */ descr-> size = data_size; descr-> data = (byte *) descr + sizeof (DESCR); if (data_block) memcpy (descr-> data, data_block, data_size); return (descr); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |