Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sofia-sip
Project
Project
Details
Activity
Releases
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
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
external
sofia-sip
Commits
b8fddfdd
Commit
b8fddfdd
authored
Nov 10, 2006
by
Pekka Pessi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
su: added function su_in_home()
darcs-hash:20061110113826-65a35-6f191ada713c5c332a1fbc9ffb702b83676fb4f8.gz
parent
f54612b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
su_alloc.h
libsofia-sip-ua/su/sofia-sip/su_alloc.h
+2
-0
su_alloc.c
libsofia-sip-ua/su/su_alloc.c
+35
-2
torture_su_alloc.c
libsofia-sip-ua/su/torture_su_alloc.c
+7
-0
No files found.
libsofia-sip-ua/su/sofia-sip/su_alloc.h
View file @
b8fddfdd
...
...
@@ -115,6 +115,8 @@ SU_DLL void *su_salloc(su_home_t *h, isize_t size)
__attribute__
((
__malloc__
));
SU_DLL
void
*
su_realloc
(
su_home_t
*
h
,
void
*
data
,
isize_t
size
)
__attribute__
((
__malloc__
));
SU_DLL
int
su_in_home
(
su_home_t
*
h
,
void
const
*
data
)
__attribute__
((
__malloc__
));
SU_DLL
char
*
su_strdup
(
su_home_t
*
home
,
char
const
*
s
)
__attribute__
((
__malloc__
));
...
...
libsofia-sip-ua/su/su_alloc.c
View file @
b8fddfdd
...
...
@@ -266,7 +266,7 @@ size_t su_block_find_collision, su_block_find_collision_used,
su_block_find_collision_size
;
#endif
static
inline
su_alloc_t
*
su_block_find
(
su_block_t
*
b
,
void
*
p
)
static
inline
su_alloc_t
*
su_block_find
(
su_block_t
*
b
,
void
const
*
p
)
{
size_t
h
,
h0
,
probe
;
...
...
@@ -854,7 +854,7 @@ void su_home_check_blocks(su_block_t const *b)
* NULL upon an error.
*
* @deprecated
* Use su_home_clone() instead of su_home_create().
* Use su_home_
new() or su_home_
clone() instead of su_home_create().
*/
su_home_t
*
su_home_create
(
void
)
{
...
...
@@ -1288,6 +1288,39 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
}
/**Check if a memory block has been allocated from the @a home.
*
* Check if the given memory block has been allocated from the home.
*
* @param home pointer to memory pool object
* @param memory ponter to memory block
*
* @retval 1 if @a memory has been allocated from @a home.
* @retval 0 otherwise
*/
int
su_in_home
(
su_home_t
*
home
,
void
const
*
memory
)
{
su_alloc_t
*
sua
;
su_block_t
*
sub
;
int
retval
=
0
;
if
(
!
home
||
!
memory
)
return
0
;
sub
=
MEMLOCK
(
home
);
if
(
sub
)
{
sua
=
su_block_find
(
sub
,
memory
);
retval
=
su_alloc_check
(
sub
,
sua
);
UNLOCK
(
home
);
}
return
retval
;
}
/**Allocate and zero a memory block.
*
* The function su_zalloc() allocates a memory block with a given size from
...
...
libsofia-sip-ua/su/torture_su_alloc.c
View file @
b8fddfdd
...
...
@@ -122,6 +122,13 @@ static int test_alloc(void)
TEST_1
(
m
=
su_zalloc
(
h2
->
home
,
20
));
TEST_1
(
su_in_home
(
h2
->
home
,
m
));
TEST_1
(
!
su_in_home
(
h2
->
home
,
(
char
*
)
m
+
1
));
TEST_1
(
!
su_in_home
(
h2
->
home
,
su_in_home
));
TEST_1
(
!
su_in_home
(
h3
->
home
,
m
));
TEST_1
(
!
su_in_home
(
NULL
,
m
));
TEST_1
(
!
su_in_home
(
h3
->
home
,
NULL
));
TEST
(
su_home_move
(
home
,
NULL
),
0
);
TEST
(
su_home_move
(
NULL
,
home
),
0
);
TEST
(
su_home_move
(
home
,
h3
->
home
),
0
);
...
...
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