MAT_VARGETSTRUCTSLINEAR(3)
MAT_VARGETSTRUCTSLINEAR π
okay bestie, this is a library function from the matio manual (section 3, the library-functions one, iykyk). it's literally called Mat_VarGetStructsLinear and it does exactly one iconic thing: linearly indexing a structure variable. slay.
β¨ SYNOPSIS β¨
#include <matio.h>
matvar_t *
Mat_VarGetStructsLinear(const matvar_t *matvar, int start, int stride,
int edge, int copy_fields);
π¦ DESCRIPTION π¦
so Mat_VarGetStructsLinear() picks out a subarray from a structure array matvar. and like, every single element in that subarray carries all of the fields of the structure β no field left behind, periodt. π
the indexing math is giving very much "skip counting at recess":
- it starts at the
startelement in the array (0 is the first element, bc of course it is) - and then it reads every
stridevalues β so1means every element,2means every other element, etc. - the total number of elements in the subarray is
edge
β οΈ heads up: the original array must have at least start+(stride-1)*edge+1 elements. that's not a suggestion, that's the vibe check the function is gonna run on your array.
now the copy_fields option β this is the main character of the whole function tbh. it says whether the fields of the original structure get copied over for the new subarray.
- if you set it to
0, the returned structure array's fields have the same pointer as the original array, and thedatafield of the subarray structure. - the subarray gets marked with the conserve memory flag, which is basically its little "do not touch" sticker β it means those fields should not be free'd by the subarray.
- they get free'd when the original structure is free'd. the original is the parent, the subarray is just borrowing the fit. π
πΈ RETURN VALUES πΈ
a subarray of the original structure array! π
or NULL if there's an error. π that's it, that's the whole range.
π SEE ALSO π
okay so that's the whole page, no cap. this little gem is from the Debian build of the manpage, dated March 14, 2012 β yeah she's a 2012 baby and she's still serving. π β¨ stay indexed, bestie. π«Άπ
π¦ where this page comes from
- arch rolling: libmatio 1.5.30-1 Β· BSD-2-Clause
- fedora 44: matio-devel 1.5.30-2.fc44 Β· BSD-2-Clause
- fedora 44: matio-devel 1.5.30-2.fc44 Β· BSD-2-Clause
- nixpkgs unstable: matio 1.5.30
- ubuntu resolute: libmatio-doc 1.5.30-2 Β· BSD-2-Clause
- ubuntu stonking: libmatio-doc 1.5.30-4build1 Β· BSD-2-Clause
- Copyright (c) 2015-2026, The matio contributors
- Copyright (c) 2012-2014, Christopher C. Hulbert
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms