Memory Allocators in FreeRTOS: heap1 to heap5 (Part 3)

Memory Allocators in FreeRTOS: heap1 to heap5 (Part 3)

heap1   Design Concept  Using fixed-size memory blocks divided into multiple equal-sized memory blocks.      Usage Process   1  Initialization  2  Call  Using xNextFreeByte as a marker, find the starting address of the unallocated bytes and return the byte position 3  Release  Not supported Understanding pvPortMalloc()   Memory allocation needs to consider two aspects of byte alignment     1  Memory allocation byte alignment  2  Memory heap starting address byte alignment   … Read more

Core Components of OpenWrt: libubox (2): Utils

Core Components of OpenWrt: libubox (2): Utils

The utils module in libubox is difficult to categorize because its functions resemble a mixed bag, so I refer to it as miscellaneous tools. It provides some simple utility functions, such as endianness conversion, bit field operations, compiler attribute wrappers, sequential memory allocation functions (calloc_a), static array size macros, assertion/error utility functions, clock time retrieval … Read more

Applications of Pointers in C Language Textbooks: A Comprehensive Overview

Applications of Pointers in C Language Textbooks: A Comprehensive Overview

For more exciting content, please click the blue text above to follow me! Continuing from the previous article《C Language Textbook: A Summary of Pointer Applications, Sharing the Differences Between Various Applications, and Unraveling the Mysteries of Pointer Usage(1)》 where we shared part of the content, this article continues. The table below summarizes the applications of … Read more

Can’t Define Variable Length Arrays in C? Don’t Be Ridiculous!

Can't Define Variable Length Arrays in C? Don't Be Ridiculous!

Hello everyone, I am Xiaokang. Today, let’s talk about a severely misunderstood feature of the C language—Variable Length Arrays! Have you heard the saying “You can’t define variable length arrays in C”? If you believed that, you have been seriously misled! Today, we will expose this widely spread “lie” and get to the bottom of … Read more

Can C Language Define Variable Length Arrays? Don’t Joke About It!

Can C Language Define Variable Length Arrays? Don't Joke About It!

Hello everyone, I am Xiaokang. Today, let’s talk about a severely misunderstood feature of the C language—Variable Length Arrays! Have you heard the saying, “Variable length arrays cannot be defined in C language”? If you believed that, you have been seriously misled! Let’s uncover this widely spread “lie” and get to the bottom of it! … Read more

How to Detect Memory Leaks in FreeRTOS

How to Detect Memory Leaks in FreeRTOS

Click on the aboveblue text to follow us In embedded systems, memory resources are often very limited, and memory leaks can lead to degraded system performance or even crashes. A memory leak refers to memory allocated by a program that is not properly released, gradually exhausting available memory. As a lightweight real-time operating system (RTOS), … Read more

Application Scenarios of Pointers: The ‘Core Tool’ in C Language

Application Scenarios of Pointers: The 'Core Tool' in C Language

Today, let’s talk about the various application scenarios of pointers in the C language. Pointers play a crucial role in programming; they are like a “core tool” that helps us manipulate data precisely in the world of memory. As a seasoned technician, I will guide you through the powerful functions of pointers in an easy-to-understand … Read more

Using the malloc Function for Dynamic Memory Allocation in C

Using the malloc Function for Dynamic Memory Allocation in C

Using the malloc Function for Dynamic Memory Allocation in C In C programming, memory management is an important topic, especially when dealing with memory that needs to be dynamically allocated. Dynamic memory allocation allows programs to request a specific amount of memory as needed, without having to declare the size of variables in advance. This … Read more

C Language Daily Challenge No. 15: Implementing a String Replacement Function

C Language Daily Challenge No. 15: Implementing a String Replacement Function

📌 Problem Description Write a function str_replace that replaces the first occurrence of an old substring with a new substring in the given string, returning the modified new string. Requirements: Only a single replacement is required The returned new string must be dynamically allocated Example: Input: str="Hello World", old="World", new="C" Output: "Hello C" Difficulty: ⭐️ … Read more

Classic C Language Interview Questions for Embedded Systems – Memory Management

Classic C Language Interview Questions for Embedded Systems - Memory Management

1. What are the methods of memory allocation in C language? ▍Technical Principles Explained In embedded systems, the memory allocation mechanism directly affects the stability and performance of programs. C language manages memory through the following three methods: Memory Allocation Methods Low-Level Mechanism Analysis: 1. Static Storage Area Lifecycle: Allocated at program startup, released at … Read more