/**
 * Fractal Runtime
 *
 * Copyright (C) 2009 STMicroelectronics
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 * Contact: mind@ow2.org
 *
 * Authors: Matthieu Leclercq
 */


/**
 * A common interface to allocate and free memory space
 */
interface memory.api.Allocator {

  /**
   * Allocates memory space
   * <p>
   * This method allocates <i>size</i> bytes and returns a pointer to the
   * allocated memory. The memory is not cleared. The value returned is a
   * pointer to the allocated memory, which is suitably aligned for any kind of
   * variable, or <code>NULL</code> if the request fails.
   *
   * @param size the amount of memory requested
   * @return pointer to the allocated memory
   */
  void *alloc(int size);

  /**
   * Frees memory space
   * <p>
   * This method frees the memory space pointed to by <code>addr</code>, which
   * must have been returned by a previous call to
   * {@link Allocator#alloc(int) alloc}. Otherwise, or if free has already been
   * called before with the same <code>addr</code>, the behavior is undefined.
   *
   * @param addr the pointer to be freed. May be <code>NULL</code>, in which
   *      case this operation does nothing.
   */
  void free(void *addr);

}