use ast_calloc instead of calloc, and do a little bit of tweaking on the code formatting
authorRussell Bryant <russell@russellbryant.com>
Sun, 26 Mar 2006 16:55:34 +0000 (16:55 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sun, 26 Mar 2006 16:55:34 +0000 (16:55 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@15026 65c4cc65-6c06-0410-ace0-fbb531ad65f3

http.c

diff --git a/http.c b/http.c
index fca0763..cdcde76 100644 (file)
--- a/http.c
+++ b/http.c
@@ -297,23 +297,21 @@ static void *http_root(void *data)
                                ast_log(LOG_WARNING, "Accept failed: %s\n", strerror(errno));
                        continue;
                }
                                ast_log(LOG_WARNING, "Accept failed: %s\n", strerror(errno));
                        continue;
                }
-               ser = calloc(1, sizeof(*ser));
-               if (ser) {
-                       ser->fd = fd;
-                       if ((ser->f = fdopen(ser->fd, "w+"))) {
-                               if (ast_pthread_create(&launched, NULL, ast_httpd_helper_thread, ser)) {
-                                       ast_log(LOG_WARNING, "Unable to launch helper thread: %s\n", strerror(errno));
-                                       fclose(ser->f);
-                                       free(ser);
-                               }
-                       } else {
-                               ast_log(LOG_WARNING, "fdopen failed!\n");
-                               close(ser->fd);
+               if (!(ser = ast_calloc(1, sizeof(*ser)))) {
+                       close(fd);
+                       continue;
+               }
+               ser->fd = fd;
+               if ((ser->f = fdopen(ser->fd, "w+"))) {
+                       if (ast_pthread_create(&launched, NULL, ast_httpd_helper_thread, ser)) {
+                               ast_log(LOG_WARNING, "Unable to launch helper thread: %s\n", strerror(errno));
+                               fclose(ser->f);
                                free(ser);
                        }
                } else {
                                free(ser);
                        }
                } else {
-                       ast_log(LOG_WARNING, "Out of memory!\n");
-                       close(fd);
+                       ast_log(LOG_WARNING, "fdopen failed!\n");
+                       close(ser->fd);
+                       free(ser);
                }
        }
        return NULL;
                }
        }
        return NULL;