diff --git a/src/system/kernel/slab/ObjectCache.h b/src/system/kernel/slab/ObjectCache.h index 1dac79088b..fc9740fdea 100644 --- a/src/system/kernel/slab/ObjectCache.h +++ b/src/system/kernel/slab/ObjectCache.h @@ -8,6 +8,7 @@ #define OBJECT_CACHE_H +#include #include #include #include @@ -140,8 +141,9 @@ link_to_object(object_link* link, size_t objectSize) static inline object_link* object_to_link(void* object, size_t objectSize) { - return (object_link*)(((uint8*)object) + BytePointer pointer((uint8*)object + (objectSize - sizeof(object_link))); + return &pointer; } diff --git a/src/system/kernel/slab/SmallObjectCache.cpp b/src/system/kernel/slab/SmallObjectCache.cpp index 7953ceaa71..8e6df40f8f 100644 --- a/src/system/kernel/slab/SmallObjectCache.cpp +++ b/src/system/kernel/slab/SmallObjectCache.cpp @@ -8,6 +8,7 @@ #include "SmallObjectCache.h" +#include #include "MemoryManager.h" #include "slab_private.h" @@ -18,7 +19,8 @@ RANGE_MARKER_FUNCTION_BEGIN(SlabSmallObjectCache) static inline slab * slab_in_pages(const void *pages, size_t slab_size) { - return (slab *)(((uint8 *)pages) + slab_size - sizeof(slab)); + BytePointer pointer(((uint8 *)pages) + slab_size - sizeof(slab)); + return &pointer; }