comparison 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
comparison
equal deleted inserted replaced
371:b6a2a305fdad 372:6639b93e81b2
1428 1428
1429 /* ngx_sort() is implemented as insertion sort because we need stable sort */ 1429 /* ngx_sort() is implemented as insertion sort because we need stable sort */
1430 1430
1431 void 1431 void
1432 ngx_sort(void *base, size_t n, size_t size, 1432 ngx_sort(void *base, size_t n, size_t size,
1433 int (*cmp)(const void *, const void *)) 1433 ngx_int_t (*cmp)(const void *, const void *))
1434 { 1434 {
1435 u_char *p1, *p2; 1435 u_char *p1, *p2, *p;
1436 u_char buf[256]; 1436
1437 p = ngx_alloc(size, ngx_cycle->log);
1438 if (p == NULL) {
1439 return;
1440 }
1437 1441
1438 for (p1 = (u_char *) base + size; 1442 for (p1 = (u_char *) base + size;
1439 p1 < (u_char *) base + n * size; 1443 p1 < (u_char *) base + n * size;
1440 p1 += size) 1444 p1 += size)
1441 { 1445 {
1442 ngx_memcpy(buf, p1, size); 1446 ngx_memcpy(p, p1, size);
1443 1447
1444 for (p2 = p1; 1448 for (p2 = p1;
1445 p2 > (u_char *) base && cmp(p2 - size, buf) > 0; 1449 p2 > (u_char *) base && cmp(p2 - size, p) > 0;
1446 p2 -= size) 1450 p2 -= size)
1447 { 1451 {
1448 ngx_memcpy(p2, p2 - size, size); 1452 ngx_memcpy(p2, p2 - size, size);
1449 } 1453 }
1450 1454
1451 ngx_memcpy(p2, buf, size); 1455 ngx_memcpy(p2, p, size);
1452 } 1456 }
1457
1458 ngx_free(p);
1453 } 1459 }
1454 1460
1455 1461
1456 #if (NGX_MEMCPY_LIMIT) 1462 #if (NGX_MEMCPY_LIMIT)
1457 1463