]> Chaos Git - corbenik/ctrulib.git/commitdiff
__alloc_handle changes for dkA r46
authorDave Murphy <davem@devkitpro.org>
Wed, 28 Dec 2016 18:27:51 +0000 (18:27 +0000)
committerDave Murphy <davem@devkitpro.org>
Mon, 16 Jan 2017 15:39:06 +0000 (15:39 +0000)
space for device specific storage in FILE struct is now allocated in __alloc_handle

libctru/source/services/soc/soc_accept.c
libctru/source/services/soc/soc_socket.c

index b00997546fce86ef111e72559c7a5e8fe06fd0a7..08262773c0fed61d617a16118bcee2763c213843 100644 (file)
@@ -8,7 +8,6 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
        int ret = 0;
        int tmp_addrlen = 0x1c;
        int fd, dev;
-       __handle *handle;
        u32 *cmdbuf = getThreadCommandBuffer();
        u8 tmpaddr[0x1c];
        u32 saved_threadstorage[2];
@@ -25,15 +24,8 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
                return -1;
        }
 
-       fd = __alloc_handle(sizeof(__handle) + sizeof(Handle));
-       if(fd < 0) {
-               errno = ENOMEM;
-               return -1;
-       }
-
-       handle = __get_handle(fd);
-       handle->device = dev;
-       handle->fileStruct = ((void *)handle) + sizeof(__handle);
+       fd = __alloc_handle(dev);
+       if(fd < 0) return fd;
 
        memset(tmpaddr, 0, 0x1c);
 
@@ -79,7 +71,10 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
                return -1;
        }
        else
+       {
+               __handle *handle = __get_handle(fd);
                *(Handle*)handle->fileStruct = ret;
+       }
 
        return fd;
 }
index 9ee007f200b31001f5c331433e89fee0dc315c05..dcff6bfd8397e12e0abca89315f3a64c79a66ba6 100644 (file)
@@ -37,11 +37,8 @@ int socket(int domain, int type, int protocol)
                return -1;
        }
 
-       fd = __alloc_handle(sizeof(__handle) + sizeof(Handle));
-       if(fd < 0) {
-               errno = ENOMEM;
-               return -1;
-       }
+       fd = __alloc_handle(dev);
+       if(fd < 0) return fd;
 
        handle = __get_handle(fd);
        handle->device = dev;