Patchwork D4111: index: pass only nodetree to nt_new()

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2018, 1:13 p.m.
Message ID <05dcd0f6a56624afdf4ad1fdc4ed85ff@localhost.localdomain>
Download mbox | patch
Permalink /patch/33319/
State Not Applicable
Headers show

Comments

phabricator - Aug. 6, 2018, 1:13 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfff675dfb80b: index: pass only nodetree to nt_new() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4111?vs=9914&id=9975

REVISION DETAIL
  https://phab.mercurial-scm.org/D4111

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1015,26 +1015,25 @@ 
 	return -4;
 }
 
-static int nt_new(indexObject *self)
+static int nt_new(nodetree *self)
 {
-	nodetree *nt = self->nt;
-	if (nt->length == nt->capacity) {
-		if (nt->capacity >= INT_MAX / (sizeof(nodetreenode) * 2)) {
+	if (self->length == self->capacity) {
+		if (self->capacity >= INT_MAX / (sizeof(nodetreenode) * 2)) {
 			PyErr_SetString(PyExc_MemoryError,
 					"overflow in nt_new");
 			return -1;
 		}
-		nt->capacity *= 2;
-		nt->nodes = realloc(nt->nodes,
-				    nt->capacity * sizeof(nodetreenode));
-		if (nt->nodes == NULL) {
+		self->capacity *= 2;
+		self->nodes = realloc(self->nodes,
+		                      self->capacity * sizeof(nodetreenode));
+		if (self->nodes == NULL) {
 			PyErr_SetString(PyExc_MemoryError, "out of memory");
 			return -1;
 		}
-		memset(&nt->nodes[nt->length], 0,
-		       sizeof(nodetreenode) * (nt->capacity - nt->length));
+		memset(&self->nodes[self->length], 0,
+		       sizeof(nodetreenode) * (self->capacity - self->length));
 	}
-	return nt->length++;
+	return self->length++;
 }
 
 static int nt_insert(indexObject *self, const char *node, int rev)
@@ -1064,7 +1063,7 @@ 
 				n->children[k] = -rev - 2;
 				return 0;
 			}
-			noff = nt_new(self);
+			noff = nt_new(self->nt);
 			if (noff == -1)
 				return -1;
 			/* self->nt->nodes may have been changed by realloc */