#include "assert.h" #include "errors/errors.h" #include "errors/exceptions.h" #include "object.h" #include "types/composites/composites.h" object nullterminated(const object string, const object memory) { assert(string.type == stringtype); assert(memory.type == stringtype); if (string.access > readonly) throw (invalidaccess); if (memory.access > readonly) throw (invalidaccess); if (string.length >= memory.length) throw (limitcheck); assert(memory.string); natural length = copy[stringtype](string, memory).length; memory.string[length++] = '\0'; return (object){ .type = stringtype, .string = memory.string, .length = length }; }