##// END OF EJS Templates
index: pass only nodetree to nt_new()...
Martin von Zweigbergk -
r38951:fff675df default
parent child Browse files
Show More
@@ -1015,26 +1015,25 b' static int nt_find(indexObject *self, co'
1015 1015 return -4;
1016 1016 }
1017 1017
1018 static int nt_new(indexObject *self)
1018 static int nt_new(nodetree *self)
1019 1019 {
1020 nodetree *nt = self->nt;
1021 if (nt->length == nt->capacity) {
1022 if (nt->capacity >= INT_MAX / (sizeof(nodetreenode) * 2)) {
1020 if (self->length == self->capacity) {
1021 if (self->capacity >= INT_MAX / (sizeof(nodetreenode) * 2)) {
1023 1022 PyErr_SetString(PyExc_MemoryError,
1024 1023 "overflow in nt_new");
1025 1024 return -1;
1026 1025 }
1027 nt->capacity *= 2;
1028 nt->nodes = realloc(nt->nodes,
1029 nt->capacity * sizeof(nodetreenode));
1030 if (nt->nodes == NULL) {
1026 self->capacity *= 2;
1027 self->nodes = realloc(self->nodes,
1028 self->capacity * sizeof(nodetreenode));
1029 if (self->nodes == NULL) {
1031 1030 PyErr_SetString(PyExc_MemoryError, "out of memory");
1032 1031 return -1;
1033 1032 }
1034 memset(&nt->nodes[nt->length], 0,
1035 sizeof(nodetreenode) * (nt->capacity - nt->length));
1033 memset(&self->nodes[self->length], 0,
1034 sizeof(nodetreenode) * (self->capacity - self->length));
1036 1035 }
1037 return nt->length++;
1036 return self->length++;
1038 1037 }
1039 1038
1040 1039 static int nt_insert(indexObject *self, const char *node, int rev)
@@ -1064,7 +1063,7 b' static int nt_insert(indexObject *self, '
1064 1063 n->children[k] = -rev - 2;
1065 1064 return 0;
1066 1065 }
1067 noff = nt_new(self);
1066 noff = nt_new(self->nt);
1068 1067 if (noff == -1)
1069 1068 return -1;
1070 1069 /* self->nt->nodes may have been changed by realloc */
General Comments 0
You need to be logged in to leave comments. Login now