Interesting realloc Functions

Source: Internet
Author: User

Among the C language's most familiar function rankings, malloc and free must be among the top, while realloc may be back. But you know, with the realloc function, you can even use it instead of malloc or free.

The function is prototype as follows:

Void * realloc (void * PTR, size_t size );

Its job is to re-allocate the memory block pointed to by the PTR parameter when the capacity is insufficient, and ensure that the content remains unchanged.

However, the function specification indicates that the PTR parameter can be null. In this case, realloc is equivalent to malloc. In addition, when the PTR parameter is not null but the size parameter is 0, it is equivalent to free.

If you are doing something similar to 64kbProgramIn this competition, I am racking my brains to save every byte. I don't want to add more import functions in the IAT of the image, so I can try my best. How about it?

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.