加载中
内存对齐

对齐原因 平台原因(移植原因):不是所有的硬件平台都能访问任意地址上的任意数据的;某些硬件平台只能在某些地址处取某些特定类型的数据,否则抛出硬件异常。 性能原因:数据结构(尤其是栈)...

2022/01/14 22:01
46
malloc(0)和free(NULL)

先看man 3 free的原话 The malloc() function allocates size bytes and returns a pointer to the allocated memory. The memory is not initialized. If size is 0, then malloc() returns...

2022/01/11 20:42
124
C++引用计数原理和实现

引用计数主要用于自动垃圾回收,C++程序直接运行于cpu,本身是没有垃圾回收功能的,但可以通过引用计数实现一个带半自动垃圾回收功能的类,之所以称之为半自动,典型的是因为它不像java/pyth...

2019/04/17 13:34
1.5K
shared_ptr源码分析

源码来自llvm 8.0.0的libc++,精简了一些不太重要的部分,重要的地方加了注释。目的是学习智能指针的实现原理。关于shared_ptr的线程安全问题,cppreference上的描述: All member functions...

2019/04/15 23:06
1.3K
C++ Simple declaration

C++是静态类型语言,提供了丰富的数据类型,它的简单声明的文法如下(摘自C++11标准): simple-declaration: decl-specifier-seq(opt) init-declarator-list(opt) ; attribute-specifier-se...

2019/04/11 11:49
163
lvalue & rvalue & lifetime

That is, an object is a contiguous region of storage; an lvalue is an expression that refers to an object. The word “lvalue” was originally coined to mean “something that ca...

2018/08/31 15:56
243

没有更多内容

加载失败,请刷新页面

没有更多内容

返回顶部
顶部