#include int path_fromobj_s(KernelObjectTyped *obj, uint8_t *buffer, int size) { size_t depth = 0, odepth = 0; for(KernelObjectTyped *o = obj->parent; o; o = o->parent, depth++); odepth = depth; if(depth > size) depth = size; for(int i = 0; i < depth; i++) { buffer[depth - i - 1] = obj->membi; obj = obj->parent; } return odepth; } int path_tobuf(KernelObjectTyped *obj, uint8_t *buffer, size_t at, size_t bufferw) { if(at + sizeof(size_t) > bufferw) return -1; size_t *buffer_pathW = (size_t*)(&buffer[at]); uint8_t *buffer_path = (uint8_t*)(&buffer_pathW[1]); size_t maxDepth = bufferw - (buffer_path - buffer); size_t objDepth = path_fromobj_s(obj, buffer_path, bufferw - (size_t)(buffer_path - buffer)); if(objDepth > maxDepth) return -1; *buffer_pathW = objDepth; return (int)(buffer_path - buffer) + objDepth; }