allocHost

Syntax

int allocHost(int size)

Arguments

size
The size of the memory block to allocate in bytes.

Return

A bufferID for the allocated memory block, or NULL if the memory couldn't be allocated (or the host program doesn't support allocated memory blocks).

Description

Allocates a block of memory through the host application. Since some graphics programs like Photoshop manage memory and allocate large chunks of memory for themselves, you might want to use this in preference to the system memory functions like malloc and calloc.

Example

int bufferID = allocHost(100);
if (bufferID == NULL) {
  Warn("Could not allocate memory");
}
else {
  char* memptr = lockHost(bufferID);
  sprintf(memptr, "Message goes here!");
  Info(memptr);
  freeHost(bufferID);
}

See Also

lockHost, freeHost