function libtest_pal_malloc

From liblfds.org
Jump to navigation Jump to search

Source Files

└───test_and_benchmark
    └───libtest
        ├───inc
        │   └───libtest
        │           libtest_porting_abstraction_layer.h
        └───src
            └───libtest_porting_abstraction_layer
                    libtest_porting_abstraction_layer_malloc.c

Prototype

void *libtest_pal_malloc( lfds711_pal_uint_t size );

Parameters

lfds711_pal_uint_t size

The length in bytes of the requested allocation.

Return Value

If successful, returns a pointer to the allocation. If unsuccessful, returns NULL. Behaviour with zero length allocation is that of the underlying call which is actually making the allocation. The code which uses this function never makes zero length allocations.

Example

void *libtest_pal_malloc( lfds711_pal_uint_t size )
{
  void
    *rv;

   // TRD : size can be any value in its range

   rv = malloc( (size_t) size );

   return rv;
}

Notes

This function is and is only used by one of the unbounded, many producer, many consumer queue tests. This particular queue permits the deallocation of elements after they have left the queue. As such, there is a test which actually mallocs, queues, then frees. If this function is implemented, the define LIBTEST_PAL_MALLOC must be created (it only needs to exist; its value is not used). If this define does not exist, then a placeholder function ends up being compiled, so that libtest can compile and in this case, the test which uses this function will not be run.

See Also