aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2018-02-21 22:25:31 +0100
committerMax <post@wickenrode.com>2018-02-21 22:25:31 +0100
commit3a944d7867c750c29e02e2619d72694bdbfb0b2a (patch)
treeedd8c5084d6488e7ccff745a87861bb4777a0373 /Frameworks/SPMySQLFramework/Source
parent6b00f5fe46c22b904ecf3f434ac859cb0fd243ca (diff)
downloadsequelpro-3a944d7867c750c29e02e2619d72694bdbfb0b2a.tar.gz
sequelpro-3a944d7867c750c29e02e2619d72694bdbfb0b2a.tar.bz2
sequelpro-3a944d7867c750c29e02e2619d72694bdbfb0b2a.zip
Remove some (near-)duplicate code
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m15
1 files changed, 4 insertions, 11 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
index d96a3b85..7d4c5a30 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
@@ -38,6 +38,7 @@
#include <string.h>
#include <stdlib.h>
#include <dlfcn.h>
+#import "SPMySQLUtilities.h"
// Thread flag constant
static pthread_key_t mySQLThreadInitFlagKey;
@@ -477,14 +478,6 @@ static errno_t LegacyMemsetS(void *ptr, rsize_t ignored, int value, rsize_t coun
const char *__crashreporter_info__ = NULL;
asm(".desc ___crashreporter_info__, 0x10");
-static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime)
-{
- uint64_t elapsedTime_t = mach_absolute_time() - comparisonTime;
- Nanoseconds elapsedTime = AbsoluteToNanoseconds(*(AbsoluteTime *)&(elapsedTime_t));
-
- return (UnsignedWideToUInt64(elapsedTime) / 1000ULL);
-}
-
@implementation SPMySQLConnection (PrivateAPI)
/**
@@ -496,8 +489,8 @@ static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime)
// If a connection is already active in some form, throw an exception
if (state != SPMySQLDisconnected && state != SPMySQLConnectionLostInBackground) {
@synchronized (self) {
- uint64_t diff = _elapsedMicroSecondsSinceAbsoluteTime(initialConnectTime);
- asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lluµs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
+ double diff = _elapsedSecondsSinceAbsoluteTime(initialConnectTime);
+ asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lfs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
__builtin_trap();
}
[NSException raise:NSInternalInconsistencyException format:@"Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).", state];
@@ -1249,7 +1242,7 @@ void PasswordCallback(MYSQL *mysql, const char *plugin, void (^with_password)(co
* The implementation is taken from the original memset_s proposal:
* http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1381.pdf
*/
-errno_t LegacyMemsetS(void *s, rsize_t smax, int c, rsize_t n)
+errno_t LegacyMemsetS(void *s, rsize_t smax __attribute__((unused)), int c, rsize_t n)
{
volatile unsigned char * addr = (volatile unsigned char *)s;
while(n--) *addr++ = (unsigned char)c;