new Alloc:arr = malloc(16);
new idx = 0;
new str[] = "Hello World";
msets(arr, idx, str);
new Alloc:arr = malloc(16);
new idx = 5;
new str[] = "Hello World";
msets(arr, idx, str, true);
new idx = 0;
// copy the contents back to buffer.
new str[12];
mgets(str, sizeof (str), arr, idx);
new idx = 5;
// copy the contents back to buffer.
new str[12];
mgets(str, sizeof (str), arr, idx, true);
new Alloc:arr = malloc(64);
new idx = 32;
new src[32] = { 5, 10, ... };
mseta(arr, idx, src, sizeof (src));
new idx = 32;
new dst[32];
mgeta(dst, sizeof (dst), arr, idx);
I.E. Initialise all the slots of the allocated memory to 0.
new Alloc:arr = calloc(16);
new Alloc:arr = malloc(16);
arr = realloc(arr, 32);
If the reallocation fails, the old pointer remains valid:
new Alloc:arr = malloc(16);
new Alloc:rea = realloc(arr, 32);
if (!rea)
{
P:E("Reallocation failed");
free(arr);
}
This allocates enough memory to store a single string, then writes that string.
new Alloc:arr = Malloc_NewS("Hello World"); // .pack = false