Permalink
Browse files

compilation fixes

  • Loading branch information...
1 parent 357a79d commit 6624d9b4f2b1b367a0e8cc194aedbc68a00eaee5 @kjk committed Apr 9, 2012
Showing with 8 additions and 10 deletions.
  1. +1 −1 c/pages.cc
  2. +7 −9 c/vec.h
View
@@ -246,7 +246,7 @@ void Pages::Insert(int page_index, const u8 *buf, int size)
Page *p = new Page(buf, len);
buf += len;
size -= len;
- page_table->InsertAt(page_index++, p);
+ page_table->InsertAt(page_index++, &p);
}
}
View
16 c/vec.h
@@ -11,13 +11,12 @@ class Vec {
public:
void EnsureCap(int needed) {
- if (this->cap > needed)
+ if (this->cap >= needed)
return;
- int newcap;
- if (this->cap < 1024)
- newcap = this->cap * 2;
- else
+ int newcap = this->cap * 2;
+ if (this->cap > 1024)
newcap = this->cap * 3 / 2;
+
if (needed > newcap)
newcap = needed;
@@ -63,8 +62,8 @@ class Vec {
return res;
}
- void InsertAt(int idx, T el) {
- MakeSpaceAt(idx, 1)[0] = el;;
+ void InsertAt(int idx, T *el) {
+ MakeSpaceAt(idx, 1)[0] = *el;
}
void Append(T *el) {
@@ -79,7 +78,7 @@ class Vec {
return -1;
}
- T RemoveAt(int idx, int count=1) {
+ void RemoveAt(int idx, int count=1) {
T res = els[idx];
int tomove = len - idx - count;
if (tomove > 0) {
@@ -88,7 +87,6 @@ class Vec {
memmove(dst, src, tomove * sizeof(T));
}
len -= count;
- return res;
}
void Push(T *el) {

0 comments on commit 6624d9b

Please sign in to comment.