diff options
| author | Paul Eggert | 2011-05-30 01:03:15 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-05-30 01:03:15 -0700 |
| commit | 9cf9f756a98922e1042e34a04368e57287e43ea6 (patch) | |
| tree | 104bf6e02aeee3712d8b1e3a7ae515cf3283239b /src | |
| parent | ed008a6dd3efc2b317643eccf4aba15c00749d27 (diff) | |
| download | emacs-9cf9f756a98922e1042e34a04368e57287e43ea6.tar.gz emacs-9cf9f756a98922e1042e34a04368e57287e43ea6.zip | |
* gnutls.c: Use Emacs's memory allocators.
Without this change, the gnutls library would invoke malloc etc.
directly, which causes problems on non-SYNC_INPUT hosts, and which
runs afoul of improving memory_full behavior.
(fn_gnutls_global_set_mem_functions): New macro or function pointer.
(emacs_gnutls_global_init): Use it to specify xmalloc, xrealloc,
xfree instead of the default malloc, realloc, free.
(Fgnutls_boot): No need to check for memory allocation failure,
since xmalloc does that for us.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 12 | ||||
| -rw-r--r-- | src/gnutls.c | 18 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b53d9b49a42..353aa100e9c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,17 @@ | |||
| 1 | 2011-05-30 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-05-30 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * gnutls.c: Use Emacs's memory allocators. | ||
| 4 | Without this change, the gnutls library would invoke malloc etc. | ||
| 5 | directly, which causes problems on non-SYNC_INPUT hosts, and which | ||
| 6 | runs afoul of improving memory_full behavior. | ||
| 7 | (fn_gnutls_global_set_mem_functions): New macro or function pointer. | ||
| 8 | (emacs_gnutls_global_init): Use it to specify xmalloc, xrealloc, | ||
| 9 | xfree instead of the default malloc, realloc, free. | ||
| 10 | (Fgnutls_boot): No need to check for memory allocation failure, | ||
| 11 | since xmalloc does that for us. | ||
| 12 | |||
| 13 | 2011-05-30 Paul Eggert <eggert@cs.ucla.edu> | ||
| 14 | |||
| 3 | * eval.c (Qdebug): Now static. | 15 | * eval.c (Qdebug): Now static. |
| 4 | * lisp.h (Qdebug): Remove decl. This reverts a part of the | 16 | * lisp.h (Qdebug): Remove decl. This reverts a part of the |
| 5 | 2011-04-26T11:26:05Z!dan.colascione@gmail.com that inadvertently undid part of | 17 | 2011-04-26T11:26:05Z!dan.colascione@gmail.com that inadvertently undid part of |
diff --git a/src/gnutls.c b/src/gnutls.c index 5558fb9ee0b..9342ce7912e 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -110,6 +110,10 @@ DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int)); | |||
| 110 | DEF_GNUTLS_FN (int, gnutls_global_init, (void)); | 110 | DEF_GNUTLS_FN (int, gnutls_global_init, (void)); |
| 111 | DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); | 111 | DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); |
| 112 | DEF_GNUTLS_FN (void, gnutls_global_set_log_level, (int)); | 112 | DEF_GNUTLS_FN (void, gnutls_global_set_log_level, (int)); |
| 113 | DEF_GNUTLS_FN (void, gnutls_global_set_mem_functions, | ||
| 114 | (gnutls_alloc_function, gnutls_alloc_function, | ||
| 115 | gnutls_is_secure_function, gnutls_realloc_function, | ||
| 116 | gnutls_free_function)); | ||
| 113 | DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); | 117 | DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); |
| 114 | DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); | 118 | DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); |
| 115 | DEF_GNUTLS_FN (int, gnutls_priority_set_direct, | 119 | DEF_GNUTLS_FN (int, gnutls_priority_set_direct, |
| @@ -168,6 +172,7 @@ init_gnutls_functions (Lisp_Object libraries) | |||
| 168 | LOAD_GNUTLS_FN (library, gnutls_global_init); | 172 | LOAD_GNUTLS_FN (library, gnutls_global_init); |
| 169 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_function); | 173 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_function); |
| 170 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_level); | 174 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_level); |
| 175 | LOAD_GNUTLS_FN (library, gnutls_global_set_mem_functions); | ||
| 171 | LOAD_GNUTLS_FN (library, gnutls_handshake); | 176 | LOAD_GNUTLS_FN (library, gnutls_handshake); |
| 172 | LOAD_GNUTLS_FN (library, gnutls_init); | 177 | LOAD_GNUTLS_FN (library, gnutls_init); |
| 173 | LOAD_GNUTLS_FN (library, gnutls_priority_set_direct); | 178 | LOAD_GNUTLS_FN (library, gnutls_priority_set_direct); |
| @@ -213,6 +218,7 @@ init_gnutls_functions (Lisp_Object libraries) | |||
| 213 | #define fn_gnutls_global_init gnutls_global_init | 218 | #define fn_gnutls_global_init gnutls_global_init |
| 214 | #define fn_gnutls_global_set_log_function gnutls_global_set_log_function | 219 | #define fn_gnutls_global_set_log_function gnutls_global_set_log_function |
| 215 | #define fn_gnutls_global_set_log_level gnutls_global_set_log_level | 220 | #define fn_gnutls_global_set_log_level gnutls_global_set_log_level |
| 221 | #define fn_gnutls_global_set_mem_functions gnutls_global_set_mem_functions | ||
| 216 | #define fn_gnutls_handshake gnutls_handshake | 222 | #define fn_gnutls_handshake gnutls_handshake |
| 217 | #define fn_gnutls_init gnutls_init | 223 | #define fn_gnutls_init gnutls_init |
| 218 | #define fn_gnutls_priority_set_direct gnutls_priority_set_direct | 224 | #define fn_gnutls_priority_set_direct gnutls_priority_set_direct |
| @@ -582,7 +588,11 @@ emacs_gnutls_global_init (void) | |||
| 582 | int ret = GNUTLS_E_SUCCESS; | 588 | int ret = GNUTLS_E_SUCCESS; |
| 583 | 589 | ||
| 584 | if (!gnutls_global_initialized) | 590 | if (!gnutls_global_initialized) |
| 585 | ret = fn_gnutls_global_init (); | 591 | { |
| 592 | fn_gnutls_global_set_mem_functions (xmalloc, xmalloc, NULL, | ||
| 593 | xrealloc, xfree); | ||
| 594 | ret = fn_gnutls_global_init (); | ||
| 595 | } | ||
| 586 | gnutls_global_initialized = 1; | 596 | gnutls_global_initialized = 1; |
| 587 | 597 | ||
| 588 | return gnutls_make_error (ret); | 598 | return gnutls_make_error (ret); |
| @@ -768,8 +778,7 @@ one trustfile (usually a CA bundle). */) | |||
| 768 | { | 778 | { |
| 769 | GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); | 779 | GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); |
| 770 | x509_cred = XPROCESS (proc)->gnutls_x509_cred; | 780 | x509_cred = XPROCESS (proc)->gnutls_x509_cred; |
| 771 | if (fn_gnutls_certificate_allocate_credentials (&x509_cred) < 0) | 781 | fn_gnutls_certificate_allocate_credentials (&x509_cred); |
| 772 | memory_full (); | ||
| 773 | 782 | ||
| 774 | if (NUMBERP (verify_flags)) | 783 | if (NUMBERP (verify_flags)) |
| 775 | { | 784 | { |
| @@ -792,8 +801,7 @@ one trustfile (usually a CA bundle). */) | |||
| 792 | { | 801 | { |
| 793 | GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); | 802 | GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); |
| 794 | anon_cred = XPROCESS (proc)->gnutls_anon_cred; | 803 | anon_cred = XPROCESS (proc)->gnutls_anon_cred; |
| 795 | if (fn_gnutls_anon_allocate_client_credentials (&anon_cred) < 0) | 804 | fn_gnutls_anon_allocate_client_credentials (&anon_cred); |
| 796 | memory_full (); | ||
| 797 | } | 805 | } |
| 798 | else | 806 | else |
| 799 | { | 807 | { |