Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
150766bb
Commit
150766bb
authored
May 16, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made memory managers use size_t to measure memory allocation sizes rather than unsigned long.
parent
ab946d7f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
31 additions
and
30 deletions
+31
-30
algs.h
dlib/algs.h
+1
-0
memory_manager_kernel_1.h
dlib/memory_manager/memory_manager_kernel_1.h
+9
-9
memory_manager_kernel_2.h
dlib/memory_manager/memory_manager_kernel_2.h
+6
-6
memory_manager_kernel_3.h
dlib/memory_manager/memory_manager_kernel_3.h
+6
-6
memory_manager_kernel_abstract.h
dlib/memory_manager/memory_manager_kernel_abstract.h
+2
-2
memory_manager_global_kernel_1.h
dlib/memory_manager_global/memory_manager_global_kernel_1.h
+2
-2
memory_manager_global_kernel_abstract.h
...ry_manager_global/memory_manager_global_kernel_abstract.h
+2
-2
memory_manager_stateless_kernel_1.h
...ory_manager_stateless/memory_manager_stateless_kernel_1.h
+1
-1
memory_manager_stateless_kernel_2.h
...ory_manager_stateless/memory_manager_stateless_kernel_2.h
+1
-1
memory_manager_stateless_kernel_abstract.h
...ager_stateless/memory_manager_stateless_kernel_abstract.h
+1
-1
No files found.
dlib/algs.h
View file @
150766bb
...
@@ -106,6 +106,7 @@ namespace std
...
@@ -106,6 +106,7 @@ namespace std
#include <algorithm> // for std::swap
#include <algorithm> // for std::swap
#include <new> // for std::bad_alloc
#include <new> // for std::bad_alloc
#include <cstdlib>
#include <cstdlib>
#include <stddef.h>
#include <limits> // for std::numeric_limits for is_finite()
#include <limits> // for std::numeric_limits for is_finite()
#include "assert.h"
#include "assert.h"
#include "error.h"
#include "error.h"
...
...
dlib/memory_manager/memory_manager_kernel_1.h
View file @
150766bb
...
@@ -14,7 +14,7 @@ namespace dlib
...
@@ -14,7 +14,7 @@ namespace dlib
template
<
template
<
typename
T
,
typename
T
,
unsigned
long
max_pool_size
size_t
max_pool_size
>
>
class
memory_manager_kernel_1
class
memory_manager_kernel_1
{
{
...
@@ -86,11 +86,11 @@ namespace dlib
...
@@ -86,11 +86,11 @@ namespace dlib
}
}
}
}
unsigned
long
get_number_of_allocations
(
size_t
get_number_of_allocations
(
)
const
{
return
allocations
;
}
)
const
{
return
allocations
;
}
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
)
)
{
{
T
*
temp
=
new
T
[
size
];
T
*
temp
=
new
T
[
size
];
...
@@ -183,9 +183,9 @@ namespace dlib
...
@@ -183,9 +183,9 @@ namespace dlib
private
:
private
:
// data members
// data members
unsigned
long
allocations
;
size_t
allocations
;
node
*
next
;
node
*
next
;
unsigned
long
pool_size
;
size_t
pool_size
;
// restricted functions
// restricted functions
memory_manager_kernel_1
(
memory_manager_kernel_1
&
);
// copy constructor
memory_manager_kernel_1
(
memory_manager_kernel_1
&
);
// copy constructor
...
@@ -231,11 +231,11 @@ namespace dlib
...
@@ -231,11 +231,11 @@ namespace dlib
{
{
}
}
unsigned
long
get_number_of_allocations
(
size_t
get_number_of_allocations
(
)
const
{
return
allocations
;
}
)
const
{
return
allocations
;
}
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
)
)
{
{
T
*
temp
=
new
T
[
size
];
T
*
temp
=
new
T
[
size
];
...
@@ -277,7 +277,7 @@ namespace dlib
...
@@ -277,7 +277,7 @@ namespace dlib
private
:
private
:
// data members
// data members
unsigned
long
allocations
;
size_t
allocations
;
// restricted functions
// restricted functions
memory_manager_kernel_1
(
memory_manager_kernel_1
&
);
// copy constructor
memory_manager_kernel_1
(
memory_manager_kernel_1
&
);
// copy constructor
...
@@ -288,7 +288,7 @@ namespace dlib
...
@@ -288,7 +288,7 @@ namespace dlib
template
<
template
<
typename
T
,
typename
T
,
unsigned
long
max_pool_size
size_t
max_pool_size
>
>
inline
void
swap
(
inline
void
swap
(
memory_manager_kernel_1
<
T
,
max_pool_size
>&
a
,
memory_manager_kernel_1
<
T
,
max_pool_size
>&
a
,
...
...
dlib/memory_manager/memory_manager_kernel_2.h
View file @
150766bb
...
@@ -13,7 +13,7 @@ namespace dlib
...
@@ -13,7 +13,7 @@ namespace dlib
template
<
template
<
typename
T
,
typename
T
,
unsigned
long
chunk_size
size_t
chunk_size
>
>
class
memory_manager_kernel_2
class
memory_manager_kernel_2
{
{
...
@@ -103,11 +103,11 @@ namespace dlib
...
@@ -103,11 +103,11 @@ namespace dlib
}
}
}
}
unsigned
long
get_number_of_allocations
(
size_t
get_number_of_allocations
(
)
const
{
return
allocations
;
}
)
const
{
return
allocations
;
}
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
)
)
{
{
T
*
temp
=
new
T
[
size
];
T
*
temp
=
new
T
[
size
];
...
@@ -184,7 +184,7 @@ namespace dlib
...
@@ -184,7 +184,7 @@ namespace dlib
++
block
;
++
block
;
// now add the rest of the block into the linked list of free nodes.
// now add the rest of the block into the linked list of free nodes.
for
(
unsigned
long
i
=
0
;
i
<
chunk_size
-
1
;
++
i
)
for
(
size_t
i
=
0
;
i
<
chunk_size
-
1
;
++
i
)
{
{
block
->
next
=
next
;
block
->
next
=
next
;
next
=
block
;
next
=
block
;
...
@@ -223,7 +223,7 @@ namespace dlib
...
@@ -223,7 +223,7 @@ namespace dlib
private
:
private
:
// data members
// data members
unsigned
long
allocations
;
size_t
allocations
;
node
*
next
;
node
*
next
;
chunk_node
*
first_chunk
;
chunk_node
*
first_chunk
;
...
@@ -238,7 +238,7 @@ namespace dlib
...
@@ -238,7 +238,7 @@ namespace dlib
template
<
template
<
typename
T
,
typename
T
,
unsigned
long
chunk_size
size_t
chunk_size
>
>
inline
void
swap
(
inline
void
swap
(
memory_manager_kernel_2
<
T
,
chunk_size
>&
a
,
memory_manager_kernel_2
<
T
,
chunk_size
>&
a
,
...
...
dlib/memory_manager/memory_manager_kernel_3.h
View file @
150766bb
...
@@ -16,7 +16,7 @@ namespace dlib
...
@@ -16,7 +16,7 @@ namespace dlib
template
<
template
<
typename
T
,
typename
T
,
unsigned
long
chunk_size
size_t
chunk_size
>
>
class
memory_manager_kernel_3
class
memory_manager_kernel_3
{
{
...
@@ -126,11 +126,11 @@ namespace dlib
...
@@ -126,11 +126,11 @@ namespace dlib
}
}
}
}
unsigned
long
get_number_of_allocations
(
size_t
get_number_of_allocations
(
)
const
{
return
allocations
;
}
)
const
{
return
allocations
;
}
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
)
)
{
{
size_t
block_size
=
sizeof
(
T
)
*
size
+
sizeof
(
size_t
)
*
2
;
size_t
block_size
=
sizeof
(
T
)
*
size
+
sizeof
(
size_t
)
*
2
;
...
@@ -252,7 +252,7 @@ namespace dlib
...
@@ -252,7 +252,7 @@ namespace dlib
++
block
;
++
block
;
// now add the rest of the block into the linked list of free nodes.
// now add the rest of the block into the linked list of free nodes.
for
(
unsigned
long
i
=
0
;
i
<
chunk_size
-
1
;
++
i
)
for
(
size_t
i
=
0
;
i
<
chunk_size
-
1
;
++
i
)
{
{
block
->
next
=
next
;
block
->
next
=
next
;
next
=
block
;
next
=
block
;
...
@@ -292,7 +292,7 @@ namespace dlib
...
@@ -292,7 +292,7 @@ namespace dlib
private
:
private
:
// data members
// data members
unsigned
long
allocations
;
size_t
allocations
;
node
*
next
;
node
*
next
;
chunk_node
*
first_chunk
;
chunk_node
*
first_chunk
;
...
@@ -370,7 +370,7 @@ namespace dlib
...
@@ -370,7 +370,7 @@ namespace dlib
template
<
template
<
typename
T
,
typename
T
,
unsigned
long
chunk_size
size_t
chunk_size
>
>
inline
void
swap
(
inline
void
swap
(
memory_manager_kernel_3
<
T
,
chunk_size
>&
a
,
memory_manager_kernel_3
<
T
,
chunk_size
>&
a
,
...
...
dlib/memory_manager/memory_manager_kernel_abstract.h
View file @
150766bb
...
@@ -52,7 +52,7 @@ namespace dlib
...
@@ -52,7 +52,7 @@ namespace dlib
causes a memory leak.
causes a memory leak.
!*/
!*/
unsigned
long
get_number_of_allocations
(
size_t
get_number_of_allocations
(
)
const
;
)
const
;
/*!
/*!
ensures
ensures
...
@@ -86,7 +86,7 @@ namespace dlib
...
@@ -86,7 +86,7 @@ namespace dlib
!*/
!*/
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
);
);
/*!
/*!
ensures
ensures
...
...
dlib/memory_manager_global/memory_manager_global_kernel_1.h
View file @
150766bb
...
@@ -43,7 +43,7 @@ namespace dlib
...
@@ -43,7 +43,7 @@ namespace dlib
virtual
~
memory_manager_global_kernel_1
(
virtual
~
memory_manager_global_kernel_1
(
)
{}
)
{}
unsigned
long
get_number_of_allocations
(
size_t
get_number_of_allocations
(
)
const
{
return
global_mm
->
get_number_of_allocations
();
}
)
const
{
return
global_mm
->
get_number_of_allocations
();
}
mm_global_type
&
get_global_memory_manager
(
mm_global_type
&
get_global_memory_manager
(
...
@@ -63,7 +63,7 @@ namespace dlib
...
@@ -63,7 +63,7 @@ namespace dlib
}
}
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
)
)
{
{
return
global_mm
->
allocate_array
(
size
);
return
global_mm
->
allocate_array
(
size
);
...
...
dlib/memory_manager_global/memory_manager_global_kernel_abstract.h
View file @
150766bb
...
@@ -81,7 +81,7 @@ namespace dlib
...
@@ -81,7 +81,7 @@ namespace dlib
get_global_memory_manager().
get_global_memory_manager().
!*/
!*/
unsigned
long
get_number_of_allocations
(
size_t
get_number_of_allocations
(
)
const
;
)
const
;
/*!
/*!
ensures
ensures
...
@@ -122,7 +122,7 @@ namespace dlib
...
@@ -122,7 +122,7 @@ namespace dlib
!*/
!*/
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
);
);
/*!
/*!
ensures
ensures
...
...
dlib/memory_manager_stateless/memory_manager_stateless_kernel_1.h
View file @
150766bb
...
@@ -48,7 +48,7 @@ namespace dlib
...
@@ -48,7 +48,7 @@ namespace dlib
}
}
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
)
)
{
{
return
new
T
[
size
];
return
new
T
[
size
];
...
...
dlib/memory_manager_stateless/memory_manager_stateless_kernel_2.h
View file @
150766bb
...
@@ -60,7 +60,7 @@ namespace dlib
...
@@ -60,7 +60,7 @@ namespace dlib
}
}
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
)
)
{
{
auto_mutex
M
(
global_mutex
());
auto_mutex
M
(
global_mutex
());
...
...
dlib/memory_manager_stateless/memory_manager_stateless_kernel_abstract.h
View file @
150766bb
...
@@ -82,7 +82,7 @@ namespace dlib
...
@@ -82,7 +82,7 @@ namespace dlib
!*/
!*/
T
*
allocate_array
(
T
*
allocate_array
(
unsigned
long
size
size_t
size
);
);
/*!
/*!
ensures
ensures
...
...
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