Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

dirstate.cpp: dirstate::read: move temp vector out of while loop

Changeset ce01b18d503e

Parent 26cc37723f8a

by Adrian Buehlmann

Changes to one file · Browse files at ce01b18d503e Showing diff from parent 26cc37723f8a Diff from another changeset...

 
122
123
124
125
126
127
128
 
129
130
131
 
134
135
136
 
 
 
 
137
138
139
 
146
147
148
149
150
151
 
 
 
 
 
152
153
154
 
122
123
124
 
 
 
 
125
126
127
128
 
131
132
133
134
135
136
137
138
139
140
 
147
148
149
 
 
 
150
151
152
153
154
155
156
157
@@ -122,10 +122,7 @@
   std::auto_ptr<dirstate> dirstate::read(const char *path)  { - direntry e; - FILE *f = 0; - - f = fopen(path, "rb"); + FILE *f = fopen(path, "rb");   if (!f)   return std::auto_ptr<dirstate>(0);   @@ -134,6 +131,10 @@
  fread(&pd->parent1, sizeof(char), HASH_LENGTH, f);   fread(&pd->parent2, sizeof(char), HASH_LENGTH, f);   + direntry e; + + std::vector<char> temp(MAX_PATH+10, 0); +   while (fread(&e.state, sizeof(e.state), 1, f) == 1)   {   fread(&e.mode, sizeof(e.mode), 1, f); @@ -146,9 +147,11 @@
  e.mtime = ntohl(e.mtime);   e.length = ntohl(e.length);   - std::vector<char> t(e.length+1, 0); - fread(&t[0], sizeof(char), e.length, f); - e.name = &t[0]; + temp.resize(e.length+1, 0); + fread(&temp[0], sizeof(char), e.length, f); + temp[e.length] = 0; + + e.name = &temp[0];     pd->add(e);   }