Show More
@@ -13,6 +13,7 b'' | |||||
13 | #include <ctype.h> |
|
13 | #include <ctype.h> | |
14 | #include <limits.h> |
|
14 | #include <limits.h> | |
15 | #include <stddef.h> |
|
15 | #include <stddef.h> | |
|
16 | #include <stdint.h> | |||
16 | #include <stdlib.h> |
|
17 | #include <stdlib.h> | |
17 | #include <string.h> |
|
18 | #include <string.h> | |
18 |
|
19 | |||
@@ -55,10 +56,10 b' typedef struct {' | |||||
55 | indexObject *index; |
|
56 | indexObject *index; | |
56 | nodetreenode *nodes; |
|
57 | nodetreenode *nodes; | |
57 | Py_ssize_t nodelen; |
|
58 | Py_ssize_t nodelen; | |
58 |
|
|
59 | size_t length; /* # nodes in use */ | |
59 |
|
|
60 | size_t capacity; /* # nodes allocated */ | |
60 |
int depth; |
|
61 | int depth; /* maximum depth of tree */ | |
61 |
int splits; |
|
62 | int splits; /* # splits performed */ | |
62 | } nodetree; |
|
63 | } nodetree; | |
63 |
|
64 | |||
64 | typedef struct { |
|
65 | typedef struct { | |
@@ -1536,10 +1537,10 b' static int nt_find(nodetree *self, const' | |||||
1536 | static int nt_new(nodetree *self) |
|
1537 | static int nt_new(nodetree *self) | |
1537 | { |
|
1538 | { | |
1538 | if (self->length == self->capacity) { |
|
1539 | if (self->length == self->capacity) { | |
1539 |
|
|
1540 | size_t newcapacity; | |
1540 | nodetreenode *newnodes; |
|
1541 | nodetreenode *newnodes; | |
1541 | newcapacity = self->capacity * 2; |
|
1542 | newcapacity = self->capacity * 2; | |
1542 |
if (newcapacity >= |
|
1543 | if (newcapacity >= SIZE_MAX / sizeof(nodetreenode)) { | |
1543 | PyErr_SetString(PyExc_MemoryError, |
|
1544 | PyErr_SetString(PyExc_MemoryError, | |
1544 | "overflow in nt_new"); |
|
1545 | "overflow in nt_new"); | |
1545 | return -1; |
|
1546 | return -1; | |
@@ -1643,7 +1644,7 b' static int nt_init(nodetree *self, index' | |||||
1643 | self->nodelen = index->nodelen; |
|
1644 | self->nodelen = index->nodelen; | |
1644 | self->depth = 0; |
|
1645 | self->depth = 0; | |
1645 | self->splits = 0; |
|
1646 | self->splits = 0; | |
1646 |
if ( |
|
1647 | if (self->capacity > SIZE_MAX / sizeof(nodetreenode)) { | |
1647 | PyErr_SetString(PyExc_ValueError, "overflow in init_nt"); |
|
1648 | PyErr_SetString(PyExc_ValueError, "overflow in init_nt"); | |
1648 | return -1; |
|
1649 | return -1; | |
1649 | } |
|
1650 | } |
General Comments 0
You need to be logged in to leave comments.
Login now