Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
40b069ca
Commit
40b069ca
authored
Mar 14, 2013
by
Kirk Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Go right in the Allocator first instead of left (allocate from the top).
parent
9d2c010e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
db/IPBuddyAlloc.pm
db/IPBuddyAlloc.pm
+16
-16
db/IPBuddyWrapper.pm
db/IPBuddyWrapper.pm
+0
-1
No files found.
db/IPBuddyAlloc.pm
View file @
40b069ca
...
...
@@ -233,9 +233,9 @@ sub requestAddressRange($$) {
}
# Helper method.
# Traverse the binary tree looking for an empty slot at the
righ
t depth.
# Traverse the binary tree looking for an empty slot at the
correc
t depth.
# Create nodes/branches as necesary to get to the requested depth. This
# procedure walks down the "
left side" of the tree, going righ
t only when
# procedure walks down the "
right side" of the tree, going lef
t only when
# it must.
#
# $self - Object reference for this class
...
...
@@ -254,14 +254,14 @@ sub _findFree($$$) {
# Are we just above the requested depth (prefix length)? If there
# is a free slot underneath, we'll use/return it!
if
(
$cn
->
getDepth
()
==
$reqdepth
-
1
)
{
if
(
!
$cn
->
hasLeft
())
{
$cn
->
setLeft
(
Tree::
Binary
->
new
({"
value
"
=>
0
,
"
term
"
=>
1
}));
return
$cn
->
getLeft
();
}
elsif
(
!
$cn
->
hasRight
())
{
if
(
!
$cn
->
hasRight
())
{
$cn
->
setRight
(
Tree::
Binary
->
new
({"
value
"
=>
1
,
"
term
"
=>
1
}));
return
$cn
->
getRight
();
}
elsif
(
!
$cn
->
hasLeft
())
{
$cn
->
setLeft
(
Tree::
Binary
->
new
({"
value
"
=>
0
,
"
term
"
=>
1
}));
return
$cn
->
getLeft
();
}
else
{
# No free slot - dead end.
return
undef
;
...
...
@@ -270,18 +270,18 @@ sub _findFree($$$) {
# Not at the terminal depth yet, so keep walking down (keeping
# left), creating nodes as necessary.
if
(
!
$cn
->
has
Lef
t
())
{
$cn
->
set
Left
(
Tree::
Binary
->
new
({"
value
"
=>
0
,
"
term
"
=>
0
}));
if
(
!
$cn
->
has
Righ
t
())
{
$cn
->
set
Right
(
Tree::
Binary
->
new
({"
value
"
=>
1
,
"
term
"
=>
0
}));
}
my
$rval
=
$self
->
_findFree
(
$cn
->
get
Lef
t
(),
$reqdepth
);
my
$rval
=
$self
->
_findFree
(
$cn
->
get
Righ
t
(),
$reqdepth
);
if
(
!
$rval
)
{
# Nothing to the
left; go righ
t...
if
(
!
$cn
->
has
Righ
t
())
{
$cn
->
set
Right
(
Tree::
Binary
->
new
({"
value
"
=>
1
,
"
term
"
=>
0
}));
# Nothing to the
right, go lef
t...
if
(
!
$cn
->
has
Lef
t
())
{
$cn
->
set
Left
(
Tree::
Binary
->
new
({"
value
"
=>
0
,
"
term
"
=>
0
}));
}
$rval
=
$self
->
_findFree
(
$cn
->
get
Righ
t
(),
$reqdepth
);
$rval
=
$self
->
_findFree
(
$cn
->
get
Lef
t
(),
$reqdepth
);
}
return
$rval
;
}
...
...
db/IPBuddyWrapper.pm
View file @
40b069ca
...
...
@@ -327,7 +327,6 @@ sub new($$$) {
}
# accessors
sub
_getobj
($)
{
return
$_
[
0
]
->
{'
IPOBJ
'};
}
sub
getrange
($)
{
return
$_
[
0
]
->
{'
RANGE
'};
}
sub
exptidx
($)
{
return
$_
[
0
]
->
{'
EXPTIDX
'};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment