473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

send params to unmanaged functions

hi.
i have gc class that wraps call to unamanged function.
im confuse with the paramter allocation and gc when sending.
i wrote small sample ,to understand if i this is ok.

__gc class MyManagedClass{
public:

void Func1(){

UNAMANGEDDLL_DATA_ST dataSt ; //not pointer
m_pArr=new UNAMANGEDDLL_DATA_ST[15]; // point to array of structs
m_pDataSt = new UNAMANGEDDLL_DATA_ST; // point to struct
unamangedFunction(dataSt,m_pArr,m_pDataSt,m_nNumbe r ); // is there
problem to send this parameter to unmanaged function ? memory
problems ?
}

private:
UNAMANGEDDLL_DATA_ST * m_pDataSt ;
int m_nNumber ;
UNAMANGEDDLL_DATA_ST * m_pArr;

}

================================================== ===============
my question is:

all of the 4 parameters are __nogc ?
the gc deal with this paramters ? move them ? free them ?
is there somthing i need to do before sending this parameters to the
unmanaged function , or its safe ?
================================================== ================
Nov 17 '05 #1
1 1015

roni wrote:
hi.
i have gc class that wraps call to unamanged function.
im confuse with the paramter allocation and gc when sending.
i wrote small sample ,to understand if i this is ok.

__gc class MyManagedClass{
public:

void Func1(){

UNAMANGEDDLL_DATA_ST dataSt ; //not pointer
m_pArr=new UNAMANGEDDLL_DATA_ST[15]; // point to array of structs m_pDataSt = new UNAMANGEDDLL_DATA_ST; // point to struct
unamangedFunction(dataSt,m_pArr,m_pDataSt,m_nNumbe r ); // is there problem to send this parameter to unmanaged function ? memory problems ?
}

private:
UNAMANGEDDLL_DATA_ST * m_pDataSt ;
int m_nNumber ;
UNAMANGEDDLL_DATA_ST * m_pArr;

}

================================================== ===============
my question is:

all of the 4 parameters are __nogc ?
the gc deal with this paramters ? move them ? free them ?
is there somthing i need to do before sending this parameters to the
unmanaged function , or its safe ?
================================================== ================


Hi Ronny.
Every thing is O.K.
You are passing two parameters by value ( dataSt and m_nNumber ), so
you don't need to care about them. You are passing two parameters as
pointers (m_pArr,m_pDataSt), they will not move in memory (they are
native type, and the new is like the old C++ new), but you do have to
delete them in unamangedFunction, as you should always do in native
code.

Alon Fliess
CTO
The Sela Group

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
5
by: Philippe Bertrand | last post by:
Using C#, I want to send a byte array to an unmanaged function with the minimum amount of copies. The array is input only and won't be modified (its copied on the unmanaged side). I'm currently...
4
by: 0to60 | last post by:
I'm trying to create a .dll with VS.NET 2003 Architect that contains a math computational component. I need the guts of the thing to be in native code, as performance is key for that part. But, I...
4
by: repstat | last post by:
Hi I have a project which is going to be doing some string manipulation which needs to be pretty fast. The user interface is going to be written in C#. I am going to write the string handling...
2
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking afterwards with ILDASM at what is visible in those assemblies from a...
0
by: Alexiel | last post by:
Hi, i have a problem, I have a Java Client and i call my webservice on ..NET. This run perfectly just except when i send parameters don't work fine. I send my code : This is my java...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
3
AMT India
by: AMT India | last post by:
I am using POST method in Ajax. I have to send a number of items through POST. So I am creating a variable like this : params += "name="+document.getElementById(name').value+"&"; params...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.