nxt_string.c (212:d532db63e8cb) nxt_string.c (216:07257705cd64)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 50 unchanged lines hidden (view full) ---

59 return dst;
60}
61
62
63/*
64 * nxt_str_cstrz() creates a C style zero-terminated copy of a source
65 * nxt_str_t. The function is intended to create strings suitable
66 * for libc and kernel interfaces so result is pointer to char instead
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 50 unchanged lines hidden (view full) ---

59 return dst;
60}
61
62
63/*
64 * nxt_str_cstrz() creates a C style zero-terminated copy of a source
65 * nxt_str_t. The function is intended to create strings suitable
66 * for libc and kernel interfaces so result is pointer to char instead
67 * of u_char to minimize casts. The copy is aligned to 2 bytes thus
68 * the lowest bit may be used as marker.
67 * of u_char to minimize casts.
69 */
70
71char *
72nxt_str_cstrz(nxt_mp_t *mp, const nxt_str_t *src)
73{
74 char *p, *dst;
75
68 */
69
70char *
71nxt_str_cstrz(nxt_mp_t *mp, const nxt_str_t *src)
72{
73 char *p, *dst;
74
76 dst = nxt_mp_align(mp, 2, src->length + 1);
75 dst = nxt_mp_alloc(mp, src->length + 1);
77
78 if (nxt_fast_path(dst != NULL)) {
79 p = nxt_cpymem(dst, src->start, src->length);
80 *p = '\0';
81 }
82
83 return dst;
84}

--- 234 unchanged lines hidden ---
76
77 if (nxt_fast_path(dst != NULL)) {
78 p = nxt_cpymem(dst, src->start, src->length);
79 *p = '\0';
80 }
81
82 return dst;
83}

--- 234 unchanged lines hidden ---