Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

explanation of following c++ code

Status
Not open for further replies.

syedshan

Advanced Member level 1
Advanced Member level 1
Joined
Feb 27, 2012
Messages
463
Helped
27
Reputation
54
Reaction score
26
Trophy points
1,308
Location
Jeonju, South Korea
Visit site
Activity points
5,134
hi

I am using 3rd party c++ code.

I want to confirm the following thing...I think now I have understood, but I still am not sure.

I have this function which sets the memory which I want to understand in actual, but the pointer it points to is a type struct inside a class c4DSP, This struct type has further another struct inside, hence what I have understood is that at this particular usage of memset is to initialize those integers and chars etc. that are residing inside the class and struct or is there any other purpose as well.

Code:
// free the memory array for the board BLAST information
	memset(&m_cBoard, 0, sizeof(m_cBoard));

then further...

Code:
class C4DSPBlast
{
public:
...
...
//! The whole BLAST information populated by GetBlastInfo() as a C data structure.
	struct BOARD m_cBoard;

}

further somewhere else in code the m_cBoard is defined as struct of type of BOARD
where BOARD struct is defined as,

Code:
struct BOARD
{
	char sDeviceType[_MAX_STRING_WIDTH];
	BANK cBankInfo[MAX_BLAST_SITES];
	int nNumberOfBanks;
};


Code:
struct BANK
{
	int nBankIndex;
	int nSiteStarID;
	long nMaxSize;
	char sSiteDescription[_MAX_STRING_WIDTH];
};
 

Yeah ,the function memset (parameters) goes to the memory location that the pointer points to((i.e) address of the structure m_cBoard and initializes all the data types to 0.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top