VecInitWithDeepCopyStack

Table of Contents

VecInitWithDeepCopyStack

Description

Initialize given vector using memory from stack. Such vectors cannot be dynamically resized. Doing so is UB. It is mandatory to initialize vectors before use. Not doing so is undefined behaviour. These vectors are best used where user doesn’t get a chance to or does not want to deinit vector, given that no data in vector needs to be deinitialized. Example includes, but does not limit to a Vec(i8), Vec(f32), etc… Stack inited vectors mustn’t be deinited after use.

Parameters

NameDirectionDescription
vin,outVector that needs to be initialized.
neinNumber of elements to allocate stack memory for.
ciinCopy init method for copying over elements in vector.
cdinCopy deinit method for deiniting elements in vector.

Usage example (from documentation)

  Vec(ModelInfo) models;
  VecInitWithDeepCopyStack(&models, 64, ModelInfoInitClone, ModelInfoDeinit, {
        // scope where vector memory is available
        VecForeachPtr(&models, model, {
            Render(model);
        });

        // Do not call deinit after use!!
  });

Usage example (Cross-references)

No external code usages found in the scanned files.

Share :