%% Pass Multilevel Pointer
% This example shows how to pass a multilevel pointer to a C function.
% Load the library containing allocateStruct and deallocateStruct.

if not(libisloaded('shrlibsample'))
    addpath(fullfile(matlabroot,'extern','examples','shrlib'))
    loadlibrary('shrlibsample')
end

%
% Create a c_structPtr pointer.

sp = libpointer('c_structPtr');

%
% Call allocateStruct to allocate memory for the structure.

res = calllib('shrlibsample','allocateStruct',sp)

%
% Free the memory created by the allocateStruct function.

calllib('shrlibsample','deallocateStruct',sp)

%
% Copyright 2015 The MathWorks, Inc.