Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyHMMER
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Larralde
PyHMMER
Commits
d61316c5
Commit
d61316c5
authored
1 year ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Fix array reallocation formula causing segfaults in `nhmmer` (#62)
parent
824962da
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#56809
passed
1 year ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/capacity.pxd
+2
-7
2 additions, 7 deletions
include/capacity.pxd
include/libhmmer/nhmmer.pxd
+5
-6
5 additions, 6 deletions
include/libhmmer/nhmmer.pxd
with
7 additions
and
13 deletions
include/capacity.pxd
+
2
−
7
View file @
d61316c5
...
...
@@ -3,11 +3,6 @@ cdef inline size_t new_capacity(size_t capacity, size_t length) nogil:
Compute a new capacity for a buffer reallocation.
This is how CPython computes the allocation sizes for the array storing
the references for a `list` object.
"""
cdef
size_t
new_cap
=
(
<
size_t
>
capacity
+
(
capacity
>>
3
)
+
6
)
&
~
(
<
size_t
>
3
)
if
(
capacity
-
length
)
>
(
new_cap
-
capacity
):
new_cap
=
(
<
size_t
>
capacity
+
3
)
&
~
(
<
size_t
>
3
)
return
new_cap
\ No newline at end of file
return
(
<
size_t
>
capacity
+
(
capacity
>>
3
)
+
6
)
&
~
(
<
size_t
>
3
)
This diff is collapsed.
Click to expand it.
include/libhmmer/nhmmer.pxd
+
5
−
6
View file @
d61316c5
from
libc.stdint
cimport
int64_t
,
uint64_t
from
libc.stdlib
cimport
calloc
,
malloc
,
realloc
,
free
from
libc.stdio
cimport
printf
cimport
libeasel
from
libhmmer.p7_tophits
cimport
P7_TOPHITS
...
...
@@ -19,7 +18,7 @@ ctypedef struct ID_LENGTH_LIST:
size_t
size
cdef
inline
ID_LENGTH_LIST
*
idlen_list_init
(
size_t
size
)
nogil
:
cdef
inline
ID_LENGTH_LIST
*
idlen_list_init
(
size_t
size
)
noexcept
nogil
:
cdef
ID_LENGTH_LIST
*
l
=
<
ID_LENGTH_LIST
*>
malloc
(
sizeof
(
ID_LENGTH_LIST
))
if
l
!=
NULL
:
l
.
count
=
0
...
...
@@ -30,13 +29,13 @@ cdef inline ID_LENGTH_LIST* idlen_list_init(size_t size) nogil:
l
=
NULL
return
l
cdef
inline
void
idlen_list_destroy
(
ID_LENGTH_LIST
*
l
)
nogil
:
cdef
inline
void
idlen_list_destroy
(
ID_LENGTH_LIST
*
l
)
noexcept
nogil
:
if
l
!=
NULL
:
if
l
.
id_lengths
!=
NULL
:
free
(
l
.
id_lengths
)
free
(
l
)
cdef
inline
int
idlen_list_add
(
ID_LENGTH_LIST
*
l
,
int64_t
id
,
int64_t
L
)
nogil
:
cdef
inline
int
idlen_list_add
(
ID_LENGTH_LIST
*
l
,
int64_t
id
,
int64_t
L
)
noexcept
nogil
:
if
l
.
count
>
0
and
l
.
id_lengths
[
l
.
count
-
1
].
id
==
id
:
l
.
id_lengths
[
l
.
count
-
1
].
length
=
L
else
:
...
...
@@ -50,7 +49,7 @@ cdef inline int idlen_list_add(ID_LENGTH_LIST* l, int64_t id, int64_t L) nogil:
l
.
count
+=
1
return
libeasel
.
eslOK
cdef
inline
int
idlen_list_assign
(
ID_LENGTH_LIST
*
l
,
P7_TOPHITS
*
th
)
nogil
:
cdef
inline
int
idlen_list_assign
(
ID_LENGTH_LIST
*
l
,
P7_TOPHITS
*
th
)
noexcept
nogil
:
cdef
uint64_t
i
cdef
int64_t
j
=
0
for
i
in
range
(
th
.
N
):
...
...
@@ -61,5 +60,5 @@ cdef inline int idlen_list_assign(ID_LENGTH_LIST* l, P7_TOPHITS* th) nogil:
th
.
hit
[
i
].
dcl
[
0
].
ad
.
L
=
l
.
id_lengths
[
j
].
length
return
libeasel
.
eslOK
cdef
inline
int
idlen_list_clear
(
ID_LENGTH_LIST
*
l
)
nogil
:
cdef
inline
int
idlen_list_clear
(
ID_LENGTH_LIST
*
l
)
noexcept
nogil
:
l
.
count
=
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment