Home >Backend Development >PHP Tutorial >basic data structure

basic data structure

WBOY
WBOYOriginal
2016-07-29 09:15:481189browse

First, the integer type:
src/core/ngx_config.h

<code><span>typedef</span> intptr_t        ngx_int_t;
<span>typedef</span> uintptr_t       ngx_uint_t;
<span>typedef</span> intptr_t        ngx_flag_t;</code>

That is, integer, unsigned integer and bool. Three types such as intptr_t are defined as follows:
/usr/local/include/stdint.h

<code><span>/* Types for `void *' pointers.  */</span><span>#if __WORDSIZE == 64</span><span># ifndef __intptr_t_defined</span>
typedef <span>long</span><span>int</span>        intptr_t;
<span>#  define __intptr_t_defined</span><span># endif</span>
typedef unsigned <span>long</span><span>int</span>   uintptr_t;
<span>#else</span><span># ifndef __intptr_t_defined</span>
typedef <span>int</span>         intptr_t;
<span>#  define __intptr_t_defined</span><span># endif</span>
typedef unsigned <span>int</span>        uintptr_t;
<span>#endif</span></code>

That is: 64-bit system uses long integer (8 bytes), otherwise uses integer (4 bytes).

Then the string type:
/src/core/ngx_string.h

<code><span>typedef</span> struct {
    size_t      len;
    u_char     *<span><span>data</span>;</span>
} ngx_str_t;
</code>

Next, a bunch of string-related functions are defined, similar to the member functions corresponding to ngx_str_t.

<code><span>typedef</span><span>struct</span> {
    ngx_str_t   key;
    ngx_str_t   value;
} ngx_keyval_t;


<span>typedef</span><span>struct</span> {  <span>// 位域用来标示类型等元信息</span><span>unsigned</span>    len:<span>28</span>;
    <span>unsigned</span>    valid:<span>1</span>;
    <span>unsigned</span>    no_cacheable:<span>1</span>;
    <span>unsigned</span>    not_found:<span>1</span>;
    <span>unsigned</span>    escape:<span>1</span>;

    u_char     *data;
} ngx_variable_value_t;
<span>typedef</span><span>struct</span> {
    ngx_rbtree_node_t         node;
    ngx_str_t                 str;
} ngx_str_node_t;</code>
The system's errno.h, and the final error number after multi-level include is defined in /usr/include/asm-generic/errno.h. The strerror and strerror_r functions are declared in string.hCopyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
Function Description
ngx_string(str) Constructor, str points to The error number is defined in src/os/unix/ngx_errno.h
The above has introduced the basic data structure, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn