Only classes with the flag zCLASS_FLAG_SHARED_OBJECTS keep track of their count (or quantity, whatever you want to call it). Sadly not many actually useful classes have this flag (it's mostly for resource management).
Also not all pointers/classes actually have a zCClassDef, so if you don't check for a valid zCClassDef pointer, you return more or less random memory (0+28 probably). This should always be allocated so I assume it won't crash, but it's bad thing to do anyway.
Check the zCClassDef pointer and return -1 if it doesn't exist.
I don't know of what use MEM_CheckIfPtrIsAnObject() could be, but in any case it would only work for classes that have the shared-flag.
Edit: It's even worse, MEM_GetClassDef() has basically no sanity checks, so if you call for a random memory address, it could either crash or just return random nonsense.
It's incredibly hard to determine whether a certain memory address is actually the start of an object and a two-liner simply will not cut it.