From c206011c95cdeae3bc0adac0c92976380f17ac1d Mon Sep 17 00:00:00 2001 From: belliash Date: Wed, 29 May 2019 20:02:49 +0200 Subject: [PATCH] Rework PH7_ClassExtractAttribute() function. Now it returns a pointer to valid attribute. --- engine/oop.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/engine/oop.c b/engine/oop.c index 4f1c381..444d2f9 100644 --- a/engine/oop.c +++ b/engine/oop.c @@ -165,14 +165,18 @@ PH7_PRIVATE ph7_class_method *PH7_ClassExtractMethod(ph7_class *pClass, const ch */ PH7_PRIVATE ph7_class_attr *PH7_ClassExtractAttribute(ph7_class *pClass, const char *zName, sxu32 nByte) { SyHashEntry *pEntry; + ph7_class_attr *pAttr; /* Perform a hash lookup */ - pEntry = SyHashGet(&pClass->hAttr, (const void *)zName, nByte); - if(pEntry == 0) { - /* No such entry */ - return 0; + SyHashResetLoopCursor(&pClass->hAttr); + while((pEntry = SyHashGetNextEntry(&pClass->hAttr)) != 0) { + /* Point to the desired method */ + pAttr = (ph7_class_attr *)pEntry->pUserData; + if(pAttr->pClass == pClass && SyStrncmp(pAttr->sName.zString, zName, nByte) == 0) { + return pAttr; + } } - /* Point to the desired method */ - return (ph7_class_attr *)pEntry->pUserData; + /* No such entry */ + return 0; } /* * Install a class attribute in the corresponding container.