IFSUPCUTILSize* size = NULL;
CoCreateInstance(CLSID_UTILSize, NULL, CLSCTX_INPROC_SERVER, IID_IFSUPCUTILSize, reinterpret_cast<void**>(&size));
if (size != NULL){
size->Release();
size = NULL;
}
delete size;
Run Code Online (Sandbox Code Playgroud)
我在上面的代码中需要"删除大小"吗?如果我包含"删除大小",我会有内存泄漏,因为我没有使用新的.或者在CoCreateInsatnce的调用中是否有新的内容.我使用VC++ 6构建它.
我的代码给出了我期望的unsigned char指针的不同长度.我认为我应该为pph和pphChar获得12(或13)或0(或1).我的问题是什么?当我重复跑步时,每次长度和长度都有不同的结果.
我怎样才能获得pph的长度?
我需要在末尾加上'\n'来确定长度吗?
我使用VS2010,XP和C++.
#include "stdafx.h"
#include <stdlib.h>
#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
typedef unsigned char uint8_t;
int _tmain(int argc, _TCHAR* argv[])
{
int length;
int len = 13;
uint8_t *phh;
char * phhChar;
printf("assigned mem %d\n", sizeof(unsigned char)*len);
phh = (unsigned char *) malloc(sizeof(unsigned char)*len);
phhChar = (char *) malloc(sizeof(char)*len);
phh[0] = (unsigned char) '1';
phh[1] = (unsigned char) '2';
phh[2] = (unsigned char) '3';
phh[3] = (unsigned char) '4';
phh[4] = (unsigned char) '5';
phh[5] = …
Run Code Online (Sandbox Code Playgroud) 我在发布配置中使用VS2010和C++
以下执行正常:
int status;
try
{
status = myfunction(arg1, arg2);
}
catch (int e)
{
cout << "An exception occurred. Exception Nr. " << e << endl;
}
Run Code Online (Sandbox Code Playgroud)
但是,以下程序崩溃了:
int status;
status = myfunction(arg1, arg2);
Run Code Online (Sandbox Code Playgroud)
发生了什么?
我没有方法的来源,myfunction,这是第三方dll的一部分.