C Interface to Scalable Allocator

Summary

Low level interface for scalable memory allocation.

Syntax

        extern "C" {
            // Scalable analogs of C memory allocator
            void* scalable_malloc( size_t size );
            void  scalable_free( void* ptr );
            void* scalable_calloc( size_t nobj, size_t size );
            void* scalable_realloc( void* ptr, size_t size );
         
            // Analog of _msize/malloc_size/malloc_usable_size.
            size_t scalable_msize( void* ptr );
         
            // Scalable analog of posix_memalign
            int scalable_posix_memalign( void** memptr, size_t alignment, 
                                         size_t size );
         
            // Aligned allocation
            void* scalable_aligned_malloc( size_t size, 
                                           size_t alignment);
            void scalable_aligned_free( void* ptr ); 
            void* scalable_aligned_realloc( void* ptr, size_t size, 
                                            size_t alignment );
        }

Header

#include "tbb/scalable_allocator.h"

Description

These functions provide a C level interface to the scalable allocator. Each routine scalable_x behaves analogously to library function x. The routines form the two families shown in the table below, "C Interface to Scalable Allocator" . Storage allocated by a scalable_x function in one family must be freed or resized by a scalable_x function in the same family, not by a C standard library function. Likewise storage allocated by a C standard library function should not be freed or resized by a scalable_x function.

C Interface to Scalable Allocator

Family

Allocation Routine

Deallocation Routine

Analogous Library

1

scalable_malloc

scalable_free

C standard library

scalable_calloc

scalable_realloc

scalable_posix_memalign

POSIX*

2

scalable_aligned_malloc

scalable_aligned_free

Microsoft* C run-time library

scalable_aligned_free

scalable_aligned_realloc

size_t scalable_msize( void* ptr )

Returns

The usable size of the memory block pointed to by ptr if it was allocated by the scalable allocator. Returns zero if ptr does not point to such a block.