Show More
@@ -1065,7 +1065,9 b' static int nt_delete_node(nodetree *self' | |||||
1065 | static int nt_init(nodetree *self, indexObject *index, unsigned capacity) |
|
1065 | static int nt_init(nodetree *self, indexObject *index, unsigned capacity) | |
1066 | { |
|
1066 | { | |
1067 | self->index = index; |
|
1067 | self->index = index; | |
1068 | self->capacity = capacity; |
|
1068 | /* The input capacity is in terms of revisions, while the field is in | |
|
1069 | * terms of nodetree nodes. */ | |||
|
1070 | self->capacity = (capacity < 4 ? 4 : capacity / 2); | |||
1069 | self->depth = 0; |
|
1071 | self->depth = 0; | |
1070 | self->splits = 0; |
|
1072 | self->splits = 0; | |
1071 | if ((size_t)self->capacity > INT_MAX / sizeof(nodetreenode)) { |
|
1073 | if ((size_t)self->capacity > INT_MAX / sizeof(nodetreenode)) { | |
@@ -1141,8 +1143,7 b' static int index_init_nt(indexObject *se' | |||||
1141 | PyErr_NoMemory(); |
|
1143 | PyErr_NoMemory(); | |
1142 | return -1; |
|
1144 | return -1; | |
1143 | } |
|
1145 | } | |
1144 | unsigned capacity = (self->raw_length < 4 ? 4 : (int)self->raw_length / 2); |
|
1146 | if (nt_init(self->nt, self, self->raw_length) == -1) { | |
1145 | if (nt_init(self->nt, self, capacity) == -1) { |
|
|||
1146 | PyMem_Free(self->nt); |
|
1147 | PyMem_Free(self->nt); | |
1147 | self->nt = NULL; |
|
1148 | self->nt = NULL; | |
1148 | return -1; |
|
1149 | return -1; |
General Comments 0
You need to be logged in to leave comments.
Login now