'Format the result from various memory search commands
Args:
- result: result of search commands (List)
- display: number of items to display
Returns:
- text: formatted text (String)'

@memoized
def format_search_result(self, result, display=256):

    text = ''
    if (not result):
        text = 'Not    found'
    else:
        maxlen = 0
        maps = self.get_vmmap()
        shortmaps = []
        for (start, end, perm, name) in maps:
            shortname = os.path.basename(name)
            if shortname.startswith('lib'):
                shortname = shortname.split('-')[0]
            shortmaps += [(start, end, perm, shortname)]
        count = len(result)
        if (display != 0):
            count = min(count, display)
        text += ('Found    %d    results,    display    max    %d    items:\n' % (len(result), count))
        for (addr, v) in result[:count]:
            vmrange = self.get_vmrange(addr, shortmaps)
            maxlen = max(maxlen, len(vmrange[3]))
        for (addr, v) in result[:count]:
            vmrange = self.get_vmrange(addr, shortmaps)
            chain = self.examine_mem_reference(addr)
            text += ('%s    :    %s' % (vmrange[3].rjust(maxlen), (format_reference_chain(chain) + '\n')))
    return text
