diff src/core/ngx_string.c @ 372:6639b93e81b2 NGINX_0_6_30

nginx 0.6.30 *) Change: now if an "include" directive pattern does not match any file, then nginx does not issue an error. *) Feature: now the time in directives may be specified without spaces, for example, "1h50m". *) Bugfix: memory leaks if the "ssl_verify_client" directive was on. Thanks to Chavelle Vincent. *) Bugfix: the "sub_filter" directive might set text to change into output. *) Bugfix: the "error_page" directive did not take into account arguments in redirected URI. *) Bugfix: now nginx always opens files in binary mode under Cygwin. *) Bugfix: nginx could not be built on OpenBSD; bug appeared in 0.6.15.
author Igor Sysoev <http://sysoev.ru>
date Tue, 29 Apr 2008 00:00:00 +0400
parents a39aab45a53f
children 984bb0b1399b
line wrap: on
line diff
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -1430,26 +1430,32 @@ ngx_escape_html(u_char *dst, u_char *src
 
 void
 ngx_sort(void *base, size_t n, size_t size,
-    int (*cmp)(const void *, const void *))
+    ngx_int_t (*cmp)(const void *, const void *))
 {
-    u_char  *p1, *p2;
-    u_char   buf[256];
+    u_char  *p1, *p2, *p;
+
+    p = ngx_alloc(size, ngx_cycle->log);
+    if (p == NULL) {
+        return;
+    }
 
     for (p1 = (u_char *) base + size;
          p1 < (u_char *) base + n * size;
          p1 += size)
     {
-        ngx_memcpy(buf, p1, size);
+        ngx_memcpy(p, p1, size);
 
         for (p2 = p1;
-             p2 > (u_char *) base && cmp(p2 - size, buf) > 0;
+             p2 > (u_char *) base && cmp(p2 - size, p) > 0;
              p2 -= size)
         {
             ngx_memcpy(p2, p2 - size, size);
         }
 
-        ngx_memcpy(p2, buf, size);
+        ngx_memcpy(p2, p, size);
     }
+
+    ngx_free(p);
 }