/* shrlibsample.c * * Sample C shared library for use with MATLAB Shared * Library Calling (CALLLIB) * Copyright 2002-2008 The MathWorks, Inc. * */ /* shrlibsample.c * * Sample C shared library for use with MATLAB Shared * Library Calling (CALLLIB) * Copyright 2002-2008 The MathWorks, Inc. * */ #include #include #include #include /* only needed because of mexFunction below and mexPrintf */ /*#include "windows.h"*/ #define EXPORT_FCNS #include "shrhelp.h" #include "shrlibsample.h" EXPORTED_FUNCTION void multDoubleArray(double *x,int size) { /* Multiple each element of the array by 3 */ int i; for (i=0;ip1+st->p2+st->p3; st->p1=5.5; st->p2=1234; st->p3=12345678; return t; } EXPORTED_FUNCTION void allocateStruct(struct c_struct** val) { /* allocate zeroed space for 5 copies of c_struct */ struct c_struct* local=(struct c_struct*) calloc(sizeof(struct c_struct),5); *val=local; /* assign val to the first set of values */ local->p1 = 12.4; local->p2 = 222; local->p3 = 333333; local++; local->p1 = 2.1; local->p2 = 22; local->p3 = 23; } EXPORTED_FUNCTION void deallocateStruct(void *ptr) { free(ptr); } EXPORTED_FUNCTION void multiplyShort(short *x, int size) { int i; for (i=0; i