Show More
@@ -1018,18 +1018,21 b' static int nt_find(indexObject *self, co' | |||
|
1018 | 1018 | static int nt_new(nodetree *self) |
|
1019 | 1019 | { |
|
1020 | 1020 | if (self->length == self->capacity) { |
|
1021 | unsigned newcapacity; | |
|
1022 | nodetreenode *newnodes; | |
|
1021 | 1023 | if (self->capacity >= INT_MAX / (sizeof(nodetreenode) * 2)) { |
|
1022 | 1024 | PyErr_SetString(PyExc_MemoryError, |
|
1023 | 1025 | "overflow in nt_new"); |
|
1024 | 1026 | return -1; |
|
1025 | 1027 | } |
|
1026 |
self->capacity * |
|
|
1027 | self->nodes = realloc(self->nodes, | |
|
1028 | self->capacity * sizeof(nodetreenode)); | |
|
1029 | if (self->nodes == NULL) { | |
|
1028 | newcapacity = self->capacity * 2; | |
|
1029 | newnodes = realloc(self->nodes, newcapacity * sizeof(nodetreenode)); | |
|
1030 | if (newnodes == NULL) { | |
|
1030 | 1031 | PyErr_SetString(PyExc_MemoryError, "out of memory"); |
|
1031 | 1032 | return -1; |
|
1032 | 1033 | } |
|
1034 | self->capacity = newcapacity; | |
|
1035 | self->nodes = newnodes; | |
|
1033 | 1036 | memset(&self->nodes[self->length], 0, |
|
1034 | 1037 | sizeof(nodetreenode) * (self->capacity - self->length)); |
|
1035 | 1038 | } |
General Comments 0
You need to be logged in to leave comments.
Login now