MCPcopy Create free account
hub / github.com/WheretIB/nullc / checkedCopy

Function checkedCopy

NULLC/CodeGen_X86.cpp:3218–3241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3216ExternTypeInfo* (*getTypeListFunc)() = GetTypeList;
3217
3218char* checkedCopy(char* top, int typeID, char* ptr, unsigned length)
3219{
3220 ExternTypeInfo* typelist = getTypeListFunc();
3221
3222 NULLCRef r;
3223 r.ptr = ptr;
3224 r.typeID = typeID;
3225 if(ptr >= top && IsPointerUnmanaged(r))
3226 {
3227 ExternTypeInfo &type = typelist[typeID];
3228 if(type.arrSize == ~0u)
3229 {
3230 char *copy = (char*)NULLC::AllocObject(typelist[type.subType].size * length);
3231 memcpy(copy, ptr, typelist[type.subType].size * length);
3232 ptr = copy;
3233 }else{
3234 unsigned int objSize = type.size;
3235 char *copy = (char*)NULLC::AllocObject(objSize);
3236 memcpy(copy, ptr, objSize);
3237 ptr = copy;
3238 }
3239 }
3240 return ptr;
3241}
3242
3243char* (*checkedCopyPtr)(char*, int, char*, unsigned) = checkedCopy;
3244

Callers

nothing calls this directly

Calls 1

IsPointerUnmanagedFunction · 0.85

Tested by

no test coverage detected