% FUNCTION BUFFER_DISPOSE(BUFFER)
%
% Feval's BUFFER.DISPOSE_FUN (if present & non-empty).
% Frees memory reserved for buffer.
%
% See BUFFER_INIT for documentation.

function buffer_dispose(buffer)

if nargin < 1
  error('buffer_dispose() needs at least 1 parameter.');
end

% Optional user-defined treatment
if isfield(buffer, 'dispose_fun')
  if ~isempty(buffer.dispose_fun)
    feval(buffer.dispose_fun, buffer);
  end
end

% Free memory
clear(inputname(1));
