1

I have char* array and I am dynamically allocating memory for it.

char *strData = new char[length+1];

This char* I am passing to _bstr_t as below,

_bstr_t bstrData = strData;

How to free up the memory allocated for the char* through bstrData ?

Eran
  • 21,632
  • 6
  • 56
  • 89
srajeshnkl
  • 883
  • 3
  • 16
  • 49

1 Answers1

2

_bstr_t manages its own internal buffer (created by SysAllocString). So once you create the _bstr_t, it's safe to delete the char array you've allocated. bstrData will still be absolutely useful.

Eran
  • 21,632
  • 6
  • 56
  • 89