Object.c 591 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. htop - Object.c
  3. (C) 2004-2012 Hisham H. Muhammad
  4. (C) 2020 Red Hat, Inc. All Rights Reserved.
  5. Released under the GNU GPLv2+, see the COPYING file
  6. in the source distribution for its full text.
  7. */
  8. #include "config.h" // IWYU pragma: keep
  9. #include "Object.h"
  10. #include <stddef.h>
  11. const ObjectClass Object_class = {
  12. .extends = NULL
  13. };
  14. bool Object_isA(const Object* o, const ObjectClass* klass) {
  15. if (!o)
  16. return false;
  17. for (const ObjectClass* type = o->klass; type; type = type->extends) {
  18. if (type == klass) {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }