Example #1
0
    def __alloc_dochunks(self, size):
        # initialize an arena if it doesn't exist
        k = 1<<bitmap.fit(size-1)

        try:
            self.arenas[k]

        except KeyError:
            self.arenas[k] = [ self.__alloc_arena(k) ]

        arena = self.arenas[k]

        # try really hard to allocate from it
        try:
            res = self.__alloc_from_bucket(arena, size)

        except ValueError:
            arena.append( self.__alloc_arena(k) )
            return self.__alloc_from_bucket(arena, size)

        return res
Example #2
0
    def __alloc_dochunks(self, size):
        # initialize an arena if it doesn't exist
        k = 1 << bitmap.fit(size - 1)

        try:
            self.arenas[k]

        except KeyError:
            self.arenas[k] = [self.__alloc_arena(k)]

        arena = self.arenas[k]

        # try really hard to allocate from it
        try:
            res = self.__alloc_from_bucket(arena, size)

        except ValueError:
            arena.append(self.__alloc_arena(k))
            return self.__alloc_from_bucket(arena, size)

        return res
Example #3
0
 def __verify(self):
     n = int(self)
     if bitmap.fit(n) > bitsize:
         print '|warning| %x is larger than %d bits. using 1 instead.'% (n, bitsize)
         self.set(1)
Example #4
0
 def __verify(self):
     n = int(self)
     if bitmap.fit(n) > bitsize:
         print('|warning| %x is larger than %d bits. using 1 instead.' %
               (n, bitsize))
         self.set(1)