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.
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);
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 ---