php kernel memcpy puzzle
学习ing
学习ing 2017-07-03 11:40:51
0
1
861
    /* concatenates "bar" after the newly reallocated large enough "FOO" */
    memcpy(ZSTR_VAL(foobar) + ZSTR_LEN(FOO), ZSTR_VAL(bar), ZSTR_LEN(bar));
学习ing
学习ing

reply all(1)
phpcn_u1582
void* memcpy(void * destination, const void * source, size_t num);

This operation is to connect "bar" to the newly reallocated space "FOO",
where ZSTR_VAL returns char*, ZSTR_LEN returns int .

Pointers can be understood as memory addresses. The pointer at the head of the existing space is ZSTR_VAL(foobar). Adding the length of space FOO backwards is the memory address at the end of FOOspace. Start from here. Memory copy, assign the value of bar (that is, ZSTR_VAL(bar)), and the length is ZSTR_LEN(bar).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template