Demo Code
#include <stdlib.h>
#include <crtdbg.h>
#include <stdint.h>
#include <iostream>
#include <memory>
using namespace std;
static int32_t g_ptr;
static int32_t g_size;
void set_data(int32_t _ptr, int32_t _size){
g_ptr = _ptr;
g_size = _size;
}
void show_data(void){
unique_ptr<char[]> str(reinterpret_cast<char *>(g_ptr));
str.get()[9] = 'c';
printf("===[%s]=[%c]==\n", str, str.get()[9]);
}
void test_data(void){
unique_ptr<char[]> str = make_unique<char[]>(10);
str.get()[0] = 'a';
str.get()[1] = 'b';
str.get()[2] = 'c';
str.get()[3] = '\0';
set_data(reinterpret_cast<int32_t>(str.get()), 10);
str.release();
}
int _tmain(int argc, _TCHAR* argv[])
{
int* pa = new int;
test_data();
show_data();
_CrtDumpMemoryLeaks();
return