From d24f0f421bf518370eb241d7666d59469e740996 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 4 Jun 2014 03:15:23 -0700 Subject: [PATCH] Add $snprintfp trampoline helper, "just in case". --- Trampoline.t.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Trampoline.t.cpp b/Trampoline.t.cpp index b3bf31d..4ebf820 100644 --- a/Trampoline.t.cpp +++ b/Trampoline.t.cpp @@ -66,6 +66,24 @@ static void $strlcpy(char *dst, const char *src, size_t size) { } dst[i] = '\0'; } +__attribute__((__unused__)) +static void $snprintfp(char *dst, size_t size, const void *pointer) { + uintptr_t value(reinterpret_cast(pointer)); + char buffer[32]; + char *end(buffer + sizeof(buffer)); + *--end = '\0'; + if (value == 0) + *--end = '0'; + else do { + unsigned digit(value & 0xf); + value >>= 4; + *--end = (digit < 10 ? '0' : 'a' - 10) + digit; + } while (value != 0); + *--end = 'x'; + *--end = '0'; + $strlcpy(dst, end, size); +} + #ifdef __LP64__ typedef struct mach_header_64 mach_header_xx; typedef struct nlist_64 nlist_xx; -- 2.49.0