def _new_mem_buf(buffer=None):
 if (buffer is None):
  bio = _lib.BIO_new(_lib.BIO_s_mem())
  free = _lib.BIO_free
 else:
  data = _ffi.new('char[]', buffer)
  bio = _lib.BIO_new_mem_buf(data, len(buffer))
  def free(bio, ref=data):
   return _lib.BIO_free(bio)
 if (bio == _ffi.NULL):
  _raise_current_error()
 bio = _ffi.gc(bio, free)
 return bio

def _new_mem_buf ( buffer = None ) : if ( buffer is None ) : bio = _lib . BIO_new ( _lib . BIO_s_mem ( ) ) free = _lib . BIO_free else : data = _ffi . new ( 'char[]' , buffer ) bio = _lib . BIO_new_mem_buf ( data , len ( buffer ) ) def free ( bio , ref = data ) : return _lib . BIO_free ( bio ) if ( bio == _ffi . NULL ) : _raise_current_error ( ) bio = _ffi . gc ( bio , free ) return bio
allocate a new openssl memory bio .