Label: malloc
malloc is a standard C library function used to allocate dynamic memory at runtime. The function reserves a block of memory of the requested size and returns a pointer to it. Unlike stack variables, memory allocated with malloc remains valid until it is explicitly released with free. If allocation fails, the function returns NULL. Developers commonly use malloc for dynamic arrays, buffers, linked lists, and other runtime data structures. The allocated memory is uninitialized and may contain arbitrary data. Incorrect use of malloc can lead to memory leaks, corruption, or crashes. Proper memory management is essential in low-level programming and performance-critical applications.
Understanding malloc is important for systems programming, memory management, and C software development.