problems in allocating new

hai;
I am facing one restart problem randomly .I debug with softice it
shows page fault. I am writing driver with driverworks.In driverworks we
directly write new as well as delete.In my program i want to use double
pointer just as below. I want to allocate this pointer just like below. it
is possible or not.

I allocate pointer like this.
short** m_pdata;

m_pData = new (NonPagedPool)short*[10];
for( index = 0; index < 5; index++ ){
m_pData[index] = new (NonPagedPool)short[100];
}
for( index = 0; index < 5; index++ ){
for( tickCount = 0; tickCount < 100; tickCount++ ){
m_pData[index][tickCount] = (short)0xFFFF;
}
}

In delete function we delete this pointer like this
if( m_pData != NULL ){
for( int index = 0; index < 5; index++ ){
if( m_pData[index] ){
delete m_pData[index], m_pData[index] = 0;
}
}

Thanks&Regards;
B.sudhakar.

You should debug your code and find what is wrong when SoftICE catches page fault. Correctness of below code is C++ question, not driver one. The code will crash as soon as some memory allocation fails because you don’t check results.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Sobana[SMTP:xxxxx@qmaxtech.com]
Reply To: Windows System Software Devs Interest List
Sent: Thursday, September 16, 2004 6:43 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] problems in allocating new

hai;
I am facing one restart problem randomly .I debug with softice it
shows page fault. I am writing driver with driverworks.In driverworks we
directly write new as well as delete.In my program i want to use double
pointer just as below. I want to allocate this pointer just like below. it
is possible or not.

I allocate pointer like this.
short** m_pdata;

m_pData = new (NonPagedPool)short*[10];
for( index = 0; index < 5; index++ ){
m_pData[index] = new (NonPagedPool)short[100];
}
for( index = 0; index < 5; index++ ){
for( tickCount = 0; tickCount < 100; tickCount++ ){
m_pData[index][tickCount] = (short)0xFFFF;
}
}

In delete function we delete this pointer like this
if( m_pData != NULL ){
for( int index = 0; index < 5; index++ ){
if( m_pData[index] ){
delete m_pData[index], m_pData[index] = 0;
}
}

Thanks&Regards;
B.sudhakar.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@upek.com
To unsubscribe send a blank email to xxxxx@lists.osr.com