Macros | Typedefs | Functions
Memory.hpp File Reference
#include "String.hpp"
Include dependency graph for Memory.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Memory__new(Type, from)   ((Type)Memory__allocate(sizeof(*((Type)0)), from))
 Allocate a Type object from the heap. More...
 

Typedefs

typedef void * Memory
 Memory is a pointer to memory. More...
 

Functions

Memory Memory__allocate (unsigned int bytes, String_Const from)
 Allocates bytes of memory and returns a pointer to it. More...
 
void Memory__free (Memory memory)
 Releases the storage associated with memory. More...
 

Macro Definition Documentation

#define Memory__new (   Type,
  from 
)    ((Type)Memory__allocate(sizeof(*((Type)0)), from))

Allocate a Type object from the heap.

The type must be a pointer type where the underlying type defintion is available to the compiler.

This allocates an object of type Type by doing "Memory_new(Type)". This macro when expanded works as follows:

   Type zilch = (Type)0;
   Uint type_size = sizeof(*zilch);
   Type type = (Type)Memory_allocate(type_size);

"sizeof(*((Type)0))" does not generate any code. The compiler evaluates it to get the number of bytes associated with "Type":

Definition at line 23 of file Memory.hpp.

Typedef Documentation

typedef void* Memory

Memory is a pointer to memory.

Definition at line 27 of file Memory.hpp.

Function Documentation

Memory Memory__allocate ( unsigned int  bytes,
String_Const  from 
)

Allocates bytes of memory and returns a pointer to it.

Parameters
bytesis the number of bytes to allocate.
fromis a debugging string.
Returns
a pointer to the allocated memory chunk.

Memory__allocate() will allocated and return a pointer to a chunk of bytes memory.

Definition at line 22 of file Memory.cpp.

void Memory__free ( Memory  memory)

Releases the storage associated with memory.

Parameters
memoryto release.

Memory__free() will release the storage associated with memory.

Definition at line 60 of file Memory.cpp.



fiducial_lib
Author(s): Wayne Gramlich
autogenerated on Thu Dec 28 2017 04:06:53