# AllocObject

Allocates memory for an object.

### Synopsis

`Err AllocObject( CObject *obj, int32 n )`

### Description

This is a method macro that is part of the Juggler object-oriented toolbox. An object's method can be called explicitly through the class structure function pointer, or with one of the defined method macros.

This method macro allocates memory for an object. It checks the amount of RAM required for the elements of the specified object, and then uses the argument n to see how many of those elements exist and need memory allocation. This function is typically used for a sequence object, in which case n specifies how many events must be stored in the sequence.

### Arguments

obj
  A pointer to the CObject data structure for the object.

n
  The number of elements that must be stored in memory.

### Return Value

This macro returns 0 if successful or an error code (a negative value) if an error occurs.

### Implementation

Macro implemented in cobj.h V20.

### Associated Files

cobj.h, music.lib

### See Also

``AllocObject`(), FreeObject(), GetNthFromObject(), GetObjectInfo(), PrintObject(), RemoveNthFromObject(), SetObjectInfo(), StartObject(), StopObject()`