C++ 查看new空间大小:修订间差异

来自泡泡学习笔记
跳到导航 跳到搜索
(创建页面,内容为“ #include<iostream> <pre> typedef struct _RTL_HEAP_ENTRY { unsigned int Size; short Flags; short AllocatorBackTraceIndex; union { struct { unsigned int Settable; long Tag; } s1; } u; } RTL_HEAP_ENTRY, *PRTL_HEAP_ENTRY; int main() { int a; int *p = new int[10]; PRTL_HEAP_ENTRY pHeapEntry=(PRTL_HEAP_ENTRY)p-1; std::cout << "size: " << pHeapEntr…”)
 
无编辑摘要
 
第1行: 第1行:
<pre>
#include<iostream>


#include<iostream>
<pre>
typedef struct _RTL_HEAP_ENTRY {
typedef struct _RTL_HEAP_ENTRY {
       unsigned int Size;
       unsigned int Size;

2024年12月4日 (三) 12:43的最新版本

#include<iostream>

typedef struct _RTL_HEAP_ENTRY {
      unsigned int Size;
      short Flags;
      short AllocatorBackTraceIndex;
      union {
              struct {
                      unsigned int Settable;
                      long Tag;
              } s1;
      } u;
} RTL_HEAP_ENTRY, *PRTL_HEAP_ENTRY;

int main() 
{
    int a;

    int *p = new int[10];
    PRTL_HEAP_ENTRY pHeapEntry=(PRTL_HEAP_ENTRY)p-1;
    std::cout << "size: " << pHeapEntry->Size << std::endl;
    std::cout << *(p - 4) << std::endl;

    delete[] p;
}