'Resize the payload to the given number of entries.
CAUTION: *nentries* must be a power of 2!'

def _resize(self, payload, nentries, errmsg):

    context = self._context
    builder = self._builder
    old_payload = payload
    ok = self._allocate_payload(nentries, realloc=True)
    with builder.if_then(builder.not_(ok), likely=False):
        context.call_conv.return_user_exc(builder, MemoryError, (errmsg,))
    payload = self.payload
    with old_payload._iterate() as loop:
        entry = loop.entry
        self._add_key(payload, entry.key, entry.hash, do_resize=False)
    self._free_payload(old_payload.ptr)
