Click here to Skip to main content
15,902,198 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Calculating Megabytes from ULONG Pin
Chuck O'Toole21-Nov-11 14:48
Chuck O'Toole21-Nov-11 14:48 
GeneralRe: Calculating Megabytes from ULONG Pin
jkirkerx21-Nov-11 15:57
professionaljkirkerx21-Nov-11 15:57 
GeneralRe: Calculating Megabytes from ULONG Pin
Stefan_Lang22-Nov-11 3:26
Stefan_Lang22-Nov-11 3:26 
GeneralRe: Calculating Megabytes from ULONG Pin
jkirkerx22-Nov-11 7:00
professionaljkirkerx22-Nov-11 7:00 
QuestionCScrollBar size Pin
Omar.Pessoa21-Nov-11 4:40
Omar.Pessoa21-Nov-11 4:40 
AnswerRe: CScrollBar size Pin
Randor 21-Nov-11 5:19
professional Randor 21-Nov-11 5:19 
GeneralRe: CScrollBar size Pin
Omar.Pessoa21-Nov-11 8:07
Omar.Pessoa21-Nov-11 8:07 
Questionmemset() run time error Pin
manju 321-Nov-11 1:23
manju 321-Nov-11 1:23 
Hi all,
I am getting some "Access violation writing " for memset for every 30 min after i run my application.
And the cursor goes to the below line:

memset(pSharedBuffer2, 0, sizeof(*pSharedBuffer2));


Here is the function i am using i am trying,and this function i am calling in timer:

#define BUF_SIZE 2048
const int max_msg = 2048;
char *pSharedBuffer2 = (char*)malloc(max_msg);
int WriteToShared()
{
	
		HANDLE handleMappedFile;
		LPVOID lpMsgBuf;
 
		handleMappedFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, HIWORD(BUF_SIZE), LOWORD(BUF_SIZE), szName4);
		if (handleMappedFile == NULL)
		{
			printf("Could not create file mapping object.\n");
			LocalFree( lpMsgBuf );
			
		}
		memset(pSharedBuffer2, 0, sizeof(*pSharedBuffer2));
 
		pSharedBuffer2 = (char*)MapViewOfFile(handleMappedFile, FILE_MAP_ALL_ACCESS, 0, 0, BUF_SIZE);
		
		
		if (pSharedBuffer2 == NULL)
		{
			printf("Could not map view of file.\n");
			CloseHandle(handleMappedFile);
			
		} 
		
 
	sprintf(i,"%d",Test);	
	addMsg1(i, pSharedBuffer2);
	
	return 0;
OnTimer()
{
WriteToShared()
}

}


Can anyone guide,whats exactly going wrong.

Thanks
Sharan
AnswerRe: memset() run time error Pin
Benjamin Bruno21-Nov-11 1:42
Benjamin Bruno21-Nov-11 1:42 
QuestionRe: memset() run time error Pin
CPallini21-Nov-11 2:13
mveCPallini21-Nov-11 2:13 
AnswerRe: memset() run time error Pin
manju 321-Nov-11 2:19
manju 321-Nov-11 2:19 
QuestionRe: memset() run time error Pin
CPallini21-Nov-11 2:44
mveCPallini21-Nov-11 2:44 
AnswerRe: memset() run time error Pin
manju 321-Nov-11 18:30
manju 321-Nov-11 18:30 
GeneralRe: memset() run time error Pin
CPallini21-Nov-11 20:06
mveCPallini21-Nov-11 20:06 
AnswerRe: memset() run time error Pin
Chuck O'Toole21-Nov-11 3:52
Chuck O'Toole21-Nov-11 3:52 
GeneralRe: memset() run time error Pin
Erudite_Eric21-Nov-11 23:10
Erudite_Eric21-Nov-11 23:10 
AnswerRe: memset() run time error Pin
Stefan_Lang21-Nov-11 5:39
Stefan_Lang21-Nov-11 5:39 
GeneralRe: memset() run time error Pin
manju 321-Nov-11 18:31
manju 321-Nov-11 18:31 
GeneralRe: memset() run time error Pin
Stefan_Lang21-Nov-11 22:37
Stefan_Lang21-Nov-11 22:37 
QuestionCIPAddressCtrl background color Pin
Benjamin Bruno21-Nov-11 0:48
Benjamin Bruno21-Nov-11 0:48 
AnswerRe: CIPAddressCtrl background color Pin
Randor 21-Nov-11 3:22
professional Randor 21-Nov-11 3:22 
AnswerRe: CIPAddressCtrl background color Pin
Satheesh154621-Nov-11 17:40
Satheesh154621-Nov-11 17:40 
Questionstring operation Pin
robin70020-Nov-11 19:21
robin70020-Nov-11 19:21 
AnswerRe: string operation Pin
«_Superman_»20-Nov-11 21:52
professional«_Superman_»20-Nov-11 21:52 
AnswerRe: string operation Pin
vr99999999921-Nov-11 1:53
vr99999999921-Nov-11 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.