logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

memins - insert bytes at beginning of memory block

Author

       Lars Wirzenius (lars.wirzenius@helsinki.fi)

Publib                                        C Programmer's Manual                                 MEMINS(3pub)

Description

memins  inserts  srcsize  bytes  from src at the beginning of tgt, but moves the first tgtsize out of the
       way.  The source and target memory blocks must not overlap.

Example

       To insert a new element at the ith position of an array, one might do the following.

            int new, array[10];

            memins(array+i, (10-i-1)*sizeof(array[0]), &new, sizeof(new));

       Please note that the above code carefully avoids the trap of moving the last element of  the  array  past
       the end of the array.

Name

       memins - insert bytes at beginning of memory block

Return Value

memins returns its first argument.

See Also

publib(3), strins(3)

Synopsis

       #include <publib.h>
       void *memins(void *tgt, size_t tgtsize, const void *src, size_t srcsize);

See Also