Basic Data Structures

Source: Internet
Author: User
First, it is an integer type:
Src/core/ngx_config.h

typedef intptr_t        ngx_int_t;typedef uintptr_t       ngx_uint_t;typedef intptr_t        ngx_flag_t;

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

/* Types for `void *' pointers.  */#if __WORDSIZE == 64# ifndef __intptr_t_definedlongint        intptr_t;#  define __intptr_t_defined# endiflongint   uintptr_t;#else# ifndef __intptr_t_definedint         intptr_t;#  define __intptr_t_defined# endifint        uintptr_t;#endif

That is: The 64 system uses a long shape (8 bytes), otherwise it uses shaping (4 bytes).

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

typedef struct {    size_t      len;    u_char     *data;} ngx_str_t;

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

function Description
Ngx_string (str) constructor, Str points to the end of the string
Ngx_null_string Empty constructors
Ngx_str_set (str, text) Text pointing to the end of the string, set it to the ngx_str_t object str
ngx_strncmp Package strncmp
ngx_strcmp Package strcmp
... ...

In addition, several other types are defined by the way:

typedefstruct {    ngx_str_t   key;    ngx_str_t   value;} ngx_keyval_t;typedefstruct {  // 位域用来标示类型等元信息unsigned    len:28;    unsigned    valid:1;    unsigned    no_cacheable:1;    unsigned    not_found:1;    unsigned    escape:1;    u_char     *data;} ngx_variable_value_t;typedefstruct {    ngx_rbtree_node_t         node;    ngx_str_t                 str;} ngx_str_node_t;

Defines your own error type: (Because the system's strerror and STRERROR_R functions are not signal-safe, so the author copies the error msg corresponding to the error code, maintains it itself, writes the function very simply, is the signal safe)
Src/os/unix/ngx_errno.h

typedefint               ngx_err_t;// 根据错误号err,将对应的描述信息拷贝到errstr,最多拷贝size字节u_char *ngx_strerror(ngx_err_t err, u_char *errstr, size_t size); ngx_int_t ngx_strerror_init(void);

The error number is defined in the system's errno.h, and the final error number after the multilayer include is defined in/usr/include/asm-generic/errno.h.
The strerror and STRERROR_R functions are declared in String.h

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The above describes the basic data structure, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.