Why Use Double Pointers to Modify Pointers in the Main Function in C?

Why Use Double Pointers to Modify Pointers in the Main Function in C?

Click the card below to follow the public account and star it to get my latest shares.Reply in the background Embedded Learning Materials to get a learning package 👇👇👇 Today I saw a question raised by a user on Zhihu: The question included a code example: void func(int *p) { p = malloc(sizeof(int)); // Only … Read more

A Beginner’s Guide to Avoiding Pitfalls in PLC Programming | A Summary from Experienced Engineers

A Beginner's Guide to Avoiding Pitfalls in PLC Programming | A Summary from Experienced Engineers

A Beginner’s Guide to Avoiding Pitfalls in PLC Programming | A Summary from Experienced Engineers In the field of industrial automation, PLCs (Programmable Logic Controllers) are no longer just simple logic control devices; they have become the intelligent control core that integrates data processing, communication, motion control, and various other functions. However, with the richness … Read more

Memory Optimization in C: Methods to Reduce Memory Usage

Memory Optimization in C: Methods to Reduce Memory Usage

In C programming, memory management is a crucial topic. Effective memory usage not only improves program performance but also avoids potential memory leaks and crashes. This article will introduce several methods to reduce memory usage in C programs, demonstrated with code examples. 1. Use Appropriate Data Types Choosing the right data type is the first … Read more

Practical Insights on C Language: A Detailed Explanation of Void Pointers

Practical Insights on C Language: A Detailed Explanation of Void Pointers

Scan the code to follow Chip Dynamics and say goodbye to “chip” congestion! Search WeChatChip Dynamics In the world of C language, pointers are the “soul tool”, but ordinary pointers (like int* and char*) are like “custom keys”—a key can only open one lock. However, the void* pointer is like a “universal key”: it can … Read more

Say Goodbye to Memory Fragmentation! A Perfect Solution for Memory Pool in Embedded Systems

Say Goodbye to Memory Fragmentation! A Perfect Solution for Memory Pool in Embedded Systems

Hello everyone, welcome to Lixin Embedded. Recently, while optimizing an industrial control project, I encountered the age-old problem of dynamic memory allocation once again. First, let’s talk about dynamic memory allocation. When coding on a PC, using new to create an object and delete to remove it is quite normal. Not enough memory? Just add … Read more

In-Depth Analysis of FreeRTOS Heap Management Mechanisms: From Heap_2 to Heap_5 Design and Implementation

In-Depth Analysis of FreeRTOS Heap Management Mechanisms: From Heap_2 to Heap_5 Design and Implementation

Introduction: An In-Depth Analysis of FreeRTOS Heap Management Mechanisms—Design and Implementation from Heap_2 to Heap_5 In embedded real-time operating systems (RTOS), dynamic memory management is one of the key factors affecting system stability and performance. FreeRTOS provides multiple heap management schemes (heap_1 to heap_5), each optimized for different application scenarios, involving memory allocation strategies, fragmentation … Read more

Explanation and Expansion on Storage Related to Keil and IAR Compilation

Explanation and Expansion on Storage Related to Keil and IAR Compilation

Weekend · A Moment of Relaxation Written in Advance I Information printed from the Keil and IAR compilation (Build) window: Program Size: Code=2596 RO-data=268 RW-data=44 ZI-data=1028 72,765 bytes of readonly code memory 3,508 bytes of readonly data memory 20,202 bytes of readwrite data memory 5,676 bytes of CODE memory 926 bytes of CONST memory 1,148 … Read more

Analysis of C++ Features from the Perspective of Assembly Language: Starting with the New Operator

Analysis of C++ Features from the Perspective of Assembly Language: Starting with the New Operator

The “Readability Crisis” of C++ Compilation Results The assembly code generated from C++ is indeed more complex than that of C, but this complexity follows certain rules: ; C language malloc call push 16 ; allocate size call malloc add esp, 4 ; C++ new operator call push 16 ; allocate size call ??2@YAPAXI@Z ; … Read more

Differences Between char*, Character Arrays, and Dynamically Allocated Strings in C Programming

Differences Between char*, Character Arrays, and Dynamically Allocated Strings in C Programming

This is a very critical and often confused knowledge point in C language: <span>char*</span>, character arrays (such as <span>char str[]</span>), and the relationship between strings. Let’s thoroughly clarify their essence, differences, and connections. 1. Basic Concepts of the Three Term Meaning <span>char*</span> Character pointer, pointing to the address of one (or more) <span>char</span> type variables … Read more

Fundamentals of Dynamic Memory Allocation in C Programming and Its Use Cases

Fundamentals of Dynamic Memory Allocation in C Programming and Its Use Cases

Dynamic memory allocation in C refers to the process where the program requests memory from the system at runtime, based on its needs, rather than determining the memory size during the compilation phase. This is key to building flexible and scalable programs. Below, I will comprehensively explain the fundamentals of dynamic memory allocation through concepts, … Read more