]> Chaos Git - corbenik/ctrulib.git/commitdiff
Moved amapp init into a seperate function.
authoryellows8 <yellows8@users.noreply.github.com>
Fri, 3 Jun 2016 00:49:01 +0000 (20:49 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Fri, 3 Jun 2016 00:49:01 +0000 (20:49 -0400)
libctru/include/3ds/services/am.h
libctru/source/services/am.c

index dc301b108e1feceb544153ad510a293cd815850b..d02650bb74c76126ad13faa8803e15a26844693c 100644 (file)
@@ -56,9 +56,12 @@ typedef struct {
        u64 titlesFreeSpace; ///< Free space for titles.
 } AM_TWLPartitionInfo;
 
-/// Initializes AM.
+/// Initializes AM. This doesn't initialize with "am:app", see amAppInit().
 Result amInit(void);
 
+/// Initializes AM with a service which has access to the amapp-commands. This should only be used when using the amapp commands, not non-amapp AM commands.
+Result amAppInit(void);
+
 /// Exits AM.
 void amExit(void);
 
index 6e3f45290f0f6e0e01a2e2e1745c269f9bb347f9..cc51e259c6ea3cf5d8d06c10a484c9f6a31b47b5 100644 (file)
@@ -20,6 +20,18 @@ Result amInit(void)
        ret = srvGetServiceHandle(&amHandle, "am:net");
        if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:u");
        if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:sys");
+       if (R_FAILED(ret)) AtomicDecrement(&amRefCount);
+
+       return ret;
+}
+
+Result amAppInit(void)
+{
+       Result ret;
+
+       if (AtomicPostIncrement(&amRefCount)) return 0;
+
+       ret = srvGetServiceHandle(&amHandle, "am:sys");
        if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:app");
        if (R_FAILED(ret)) AtomicDecrement(&amRefCount);