]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blobdiff - src/rm_allocator.c
Preallocation routine will now correctly get next tree node during resource search
[keystone-rtos/rm-lld.git] / src / rm_allocator.c
index b36dd37a657d495d4fb11b2466886b6ac0a9b31c..0e74966c6ff6aabc5be411b2f543da058517a518 100644 (file)
@@ -386,6 +386,7 @@ static int32_t allocatorPreAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator,
     Rm_Inst           *rmInst = (Rm_Inst *)rmHandle;
     Rm_ResourceNode    findNode;
     Rm_ResourceNode   *matchingNode = NULL;
+    Rm_ResourceNode   *nextNode;
     uint32_t           matchingEnd;
     uint32_t           findEnd;
     uint32_t           rangeIndex;
@@ -509,7 +510,12 @@ static int32_t allocatorPreAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator,
                     findNode.base = matchingNode->base;
                 }
                 else {
-                    findNode.base = matchingNode->base + matchingNode->length;
+                    if (nextNode = RB_NEXT(_Rm_AllocatorResourceTree, allocator->allocatorRootEntry, matchingNode)) {
+                        findNode.base = nextNode->base;
+                    }
+                    else {
+                        retVal = RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET;
+                    }
                 }
             }
         }
@@ -1355,7 +1361,7 @@ int rmAllocatorGetNodeLocalization(Rm_Handle rmHandle, char *resourceName,
     Rm_Inst         *rmInst = (Rm_Inst *)rmHandle;
     void *           policy = rmPolicyGetPolicy((Rm_Handle)rmInst);
     int32_t          resOffsetInPolicy = rmPolicyGetResourceOffset(policy, resourceName);
-    uint32_t         allocSize = rmPolicyGetResourceAllocSize(policy, resOffsetInPolicy);    
+    uint32_t         allocSize = rmPolicyGetResourceCdAllocSize(policy, resOffsetInPolicy);    
     Rm_Allocator    *allocator = rmAllocatorFind(rmHandle, resourceName);
     Rm_ResourceNode  findNode;
     Rm_ResourceNode *matchingNode = NULL;