Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove mod in round-to-page-size function

  • Loading branch information...
commit ed38db520cb2dfe2dc3703249bc23bd2778c7349 1 parent 2390f90
Kevin Lawler kevinlawler authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 km.c
6 km.c
View
@@ -17,7 +17,6 @@ I PG; //pagesize: size_t page_size = (size_t) sysconf (_SC_PAGESIZE);
Z I cl2(I v);
Z I kexpander(K *p,I n);
-Z I nearest(I i,I m);
Z K kapn_(K *a,V *v,I n);
Z V amem(I k);
Z V kalloc(I k);
@@ -60,9 +59,8 @@ K ci(K a){if(a)a->c++; R a;}
I bp(I t) {SW(ABS(t)){CSR(1, R sizeof(I)) CSR(2, R sizeof(F)) CSR(3, R sizeof(C)) default: R sizeof(V); } } //Default 0/+-4/5/6/7 (assumes sizeof(K)==sizeof(S)==...)
I sz(I t,I n){R 3*sizeof(I)+(7==t?TYPE_SEVEN_SIZE:n)*bp(t)+(3==ABS(t));} //not recursive. assert sz() > 0: Everything gets valid block for simplified munmap/(free)
-Z I nearest(I i,I m){I k=i%m;R k?i+m-k:i;} //up 0,8,...,8,16,16,...
-#define nearPG(i) nearest((i),PG)
-//#define nearI(i) nearest((i),sizeof(I))
+
+Z I nearPG(I i){ I k=((size_t)i)&(PG-1);R k?i+PG-k:i;}//up 0,8,...,8,16,16,...
//This is an untested idea for avoiding all that goes on in backing out of memory allocations when an error occurs inside a function before everything is done:
//If you control the memory allocator one possibility is to work in "claimed" (sbreak) but "free" space and build the K data structure there.
Please sign in to comment.
Something went wrong with that request. Please try again.