Dynamic memory allocation: malloc, calloc, and realloc

1, Why dynamic memory allocation When we declare an array in c language, we must first specify the size of an array, but in practice, we often can't know the size of the array we set in advance. For example, suppose we want to count the data of all students in a class, but the number of students in different classes may be different. In ...

Posted by mnetsys on Tue, 30 Nov 2021 02:51:57 -0800

Simple thread pool

outline Author in Simple thread pool In this paper, the author will use blocking thread synchronization to realize the thread pool with the same characteristics. This article will not repeat and Simple thread pool The same content. If there is any ambiguity, please refer to This blog. realization The following code shows the implementation of ...

Posted by freakstyle on Mon, 29 Nov 2021 23:13:08 -0800

Tree array to solve the number of pairs in reverse order (including introduction to tree array)

Before learning the tree array to solve the reverse pair. First, let's briefly learn about tree arrays. First, let's explore four problems. 1. What is a tree array? See the name and meaning, is to use arrays to simulate tree structures. Then another question arises, why not make achievements directly? The answer to this question is not ne ...

Posted by trassalg on Mon, 29 Nov 2021 22:04:12 -0800

[C + + learning] IO Library

Part II C + + standard library The core of the standard library is many container classes and a family of generic algorithms. These facilities can help us write concise and efficient programs. The standard library will pay attention to the details of bookkeeping operations, especially memory management, so that our programs can devote all thei ...

Posted by clodagh2000 on Mon, 29 Nov 2021 20:56:48 -0800

In depth understanding of computer systems (Third Edition) - Chapter 6 - cache lab

The experiment in this chapter is quite interesting. Simply record the practice. 1, partA partA is relatively simple. It should be noted that the use of LRU and different lines in the same set do not store continuous addresses. Take s = 1, E = 2, b = 1 as an example: the first row of the first set stores 0x2 0xa ···, ...

Posted by Ghostgator on Mon, 29 Nov 2021 20:21:47 -0800

Thoughts on cc3k village operation

Thoughts on cc3k village operation When I finished this assignment in object-oriented curriculum design, I haven't summarized my experience. Today, take the opportunity to answer the students' questions to summarize. Before starting The teacher asked to implement it in C + +, but on the other hand, I only knew this language at that time. At ...

Posted by hemoglobina on Sun, 28 Nov 2021 18:43:06 -0800

IO multiplexing (select, poll, epoll)

The TCP server can be explained with the following diagram: Welcome is equivalent to listenfd, which has been listening to the client's requests. When a customer arrives, guide the customer to the waiter in the lobby. At this time, a connection is established. The lobby waiter is equivalent to connfd, and all interactions with the current clien ...

Posted by egiblock on Sun, 28 Nov 2021 13:28:56 -0800

C + + self implementation String

Mstring infrastructure #ifndef MSTRING_H #define MSTRING_H #include<iostream> using namespace std; #define MSTRING_NUM_SIZE sizeof(int) / / reference count size #define DEFEALT_LEN (10+MSTRING_NUM_SIZE) class Mstring { public: Mstring(const char* str); Mstring(const Mstring& src); Mstring& operator=(const Mstring& ...

Posted by FinalMjolnir on Sun, 28 Nov 2021 12:55:24 -0800

11-[LVI-SAM]visual_ feature_ img_ Analysis of callback

2021SC@SDUSC visual_ feature_ img_ Analysis of callback In the previous blog, we analyzed one of the callback functions lidar in LVI-SAM_ callback. Through the last blog, we know lidar_callback subscribes to the lidar message and obtains the read-up information through processing, and then puts the dot graph with depth information into the s ...

Posted by zeddeh on Sun, 28 Nov 2021 10:14:35 -0800

lettcode algorithm problem punch in - day05

Maximum depth of binary tree Given a binary tree, find its maximum depth. The depth of the binary tree is the number of nodes on the longest path from the root node to the farthest leaf node. explain:   A leaf node is a node that has no children. Example: Given binary tree [3,9,20,null,null,15,7],     3    / \   9  20     /  \    15 ...

Posted by riwan on Sun, 28 Nov 2021 08:52:54 -0800