8.15. File tom/C

class tom.C

The C class provides low-level memory manipulation functionality. With it, a lot of collection and string methods can be written in TOM instead of needing to be written in C.

inherits

Behaviour supers: All

methods


void
  free pointer address;

Release the memory at address.


pointer
  malloc int length;

Return a pointer to a newly allocated memory region of length bytes.


pointer
  calloc (int, int) (num, bytes);

Return a pointer to newly allocated and zeroed memory region of num elements of each bytes size.


pointer
  realloc (pointer, int) (address, length);

Return a pointer to the resized memory region at address which must hold length bytes. The address returned can differ from the previous address.


int
  memcmp (pointer, pointer, int) (one, other, length);

Return 0 iff the length bytes at one equal the bytes at other.


int
  memchr (pointer, int, int) (p, c, length);

Search the first length bytes from s for character c. Return the index into s at which c first occurs. If c is not present, return the value -1.


pointer
  memcpy (pointer, pointer, int) (to, from, length);

Copy the length bytes from from to to. Return to.


pointer
  memmove (pointer, pointer, int) (to, from, length);

Copy the length bytes from from to to, safely. Return to.


void
  bzero (pointer, int) (p, num);

Set the num bytes at p to 0.

instance tom.C

The C instance can be and is totally empty.