|
The maximum addressable memory is not 4 * (232-1), but rather (232-1), so there is no problem of the sort you describe. What a pointer stores is the address of a single byte (a char , roughly speaking,) not a full 32-bit word.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
An Intel-architecture PC is a byte-addressable machine but you seem to be thinking about word-addressable machines which are quite rare nowadays.
Each byte has its own memory address, so the addressable memory space for a single process (without funny tricks with segment registers) is 4 GiBytes, not 4 GiWords. All the memory space is addressable with 32 bit pointers.
|
|
|
|
|
I've been hunting around and haven't dug up anything yet. I actually wrote one myself but I am not happy with it. I am about to start again but was hoping that maybe someone worked out all the kinks in some generic form I could adapt.
I have a rather large project that uses something very similar to a variant object. I can have anywhere from 10 to 50,000 instance of these classes at any one time and they are created and destroyed many, many times during the program's execution (which may last weeks at a time - Windows permitting). I want to avoid memory fragmentation and just make this application more speedy in general.
Thanks,
Paul
|
|
|
|
|
For STL containers, I wrote some time ago a block allocator that you can find here[^]. Most likely you're not using STL, but even so it's not hard to encapsulate the class into an interface that better suits your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks!
I looked at it and I think I might be able to use it. I was concerned of the MS compiler issues with templates but your code comments to that effect are helpful. If I can come up with a general, generic form of this that can be used for any class, I might post it to this site (with due credit to you).
Thanks again,
Paul
|
|
|
|
|
Hi Paul,
Much of the interface present in block_allocator is meant only to comply with STL requirements and it's not useful for a general pool class. The following is a (not even compiled) sketch of what a general pool class might look like:
#include "blockallocator.h"
template <typename T,size_t chunk_size> pool
{
public:
T* create(T& t=T())
{
T* p=reinterpret_cast<T*>(alloc._Charalloc(sizeof(T)));
alloc.construct(p,t);
return p;
}
void destroy(T* p)
{
alloc.destroy(p);
alloc.deallocate(p,1);
}
private:
pool(const pool&);
pool& operator=(const pool&);
block_allocator<T,T,chunk_size> alloc;
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Where the heck is the profiler ? I've enabled profiling in my project setting,
I know I have to go thru (sp?) the VC install, but I didn't see it. is it on the other install CD ? I only have CD1 with me.
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
How can i change the color for a ListBox's text and background in Vc++ ?
|
|
|
|
|
One solution is custom draw. Derive a class from CListBox or whatever is do custom draw on the background.
Kuphryn
|
|
|
|
|
I need to find out if Subclassing is the only option. I would like to know if it can be done in other ways without sub classing . I was assuming that when u can have a method to change the Font in a List or Edit box there should surely be a method to do Color change !
|
|
|
|
|
Look into WM_CTLCOLORLISTBOX .
Jeremy Falcon
|
|
|
|
|
Hello,
can You tell me how to print various page number with MFC?for example,i have a variable X which user enters and i want to print X pages and every page have different text:
"This is Page %X"
Thanks.;)
|
|
|
|
|
Anyone know of a reliable way to get the MAC address(es) for installed NIC(s) on the system?
Jeremy Falcon
|
|
|
|
|
Warren Young's Winsock Progammer's FAQ has a section[^] devoted to this.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the link!
Jeremy Falcon
|
|
|
|
|
Hey,
my goal is to show different dialog within a CTabCtrl depend on the selected tab item.
How can I display a dialog (Resource with DialogClass) in my TabCtrl. I tried the following, but it didn't work as expected:
header-file:
CMyDialog myDialog; //DialogClass
cpp-file:
<br />
m_tab.InsertItem(0, _T("Test1"));<br />
m_tab.InsertItem(1, _T("Test2"));<br />
<br />
CRect reTabCtrl, reListCtrl;<br />
<br />
m_tab.GetClientRect(&reTabCtrl);<br />
<br />
m_myDialog.Create(IDD_DIA_STANDARD, m_tab.GetWindow(0));<br />
<br />
m_myDialog.SetWindowPos(NULL,reTabCtrl.left,reTabCtrl.top,100,200,SWP_NOZORDER);<br />
<br />
myDialog.ShowWindow(SW_SHOW);<br />
<br />
|
|
|
|
|
Hi
I need to use 'RegQueryValueEx(...)' to retrieve a subkey's value.
<br />
CString strReturnWaarde("");<br />
long lResult=0L;<br />
DWORD dwLength=0L, dwType=0L;<br />
TCHAR keyValue[256];<br />
<br />
HKEY SrcKey;<br />
<br />
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\COMPANY\\PRODUCT\\" + strKey, 0, KEY_READ, &SrcKey) == ERROR_SUCCESS ) <br />
{<br />
dwLength = 256*sizeof(TCHAR);<br />
lResult = RegQueryValueEx(SrcKey,strKeyName, NULL, &dwType, (BYTE*)keyValue, &dwLength );<br />
<br />
if ( lResult == ERROR_SUCCESS )<br />
{<br />
strReturnWaarde = CString(keyValue);<br />
} <br />
RegCloseKey(SrcKey);<br />
}<br />
::AfxMessageBox(strReturnWaarde);<br />
This code works when getting Text but not when trying to get numbers (DWORD).
What is wrong with it? :x
I replaced the 'strReturnWaarde' as ' int iReturnWaarde' and without the conversation to CString ofcourse.
Greetings
Jens
|
|
|
|
|
Hi,
The problem is in typcasting. It is right to cast the type into a pointer to byte (LPBYTE) but then you have to provide the adress of your DWORD variable too. Also keyValue must be of type DWORD.
Like:
<br />
DWORD dwType,dwLength,keyValue;<br />
...<br />
RegResult=::RegQueryValueEx(SrcKey,strKeyName,NULL,&dwType,(LPBYTE)&(keyValue),&dwLength);<br />
You may not use a TCHAR buffer array for this purpose. I couldn't find a way to cast this in a DWORD.;)
Regards
G. Steudtel
|
|
|
|
|
I have a dilemna. I have not used c++ in years in been thrown in to a project, that should be fairly simple, if I could remember anything about c++. I have a log file that I currently parse looking only for a specific set of data. The program parses the line that I need which is similiar to this:
Test Data A:1234\1234\12345678.dat File error: "Then the Error Message" to A:1234\1234\12345678.dat.$$$.WeekDay Month Day Time Year
I parse out the file looking for Test Data, displaying the entire line to write to the file in the directory.(a Then I need to compare the Error Message with the current possible error messages, if a match is found, write a note in the file stating what the error message means. I am having extreme difficulty getting the program to compare the error message to the possible error message and displaying another.
Copy of Code:
CFile file;
CFile outputfile;
CFileException exception;
int holder = (80);
if (!file.Open(fileNameStr, CFile::modeRead, &exception))
{
return false;
}
int count = 0;
char buffer;
CString TempBuffer;
CParser parser;
parser.Add((int)TOKEN_DATA_FILE, "Test Data ");
parser.Add((int)TOKEN_SECOND, "File Copy Failed on Data File ");
// parser.Add((int)TOKEN_DATA_M, "A: ");
parser.Add((int)TOKEN_MESS_1, "failed decryption ");
parser.Add((int)TOKEN_MESS_2, "Failed Decryption but Decompressed ");
parser.Add((int)TOKEN_MESS_3, "Failed Decompression ");
parser.Add((int)TOKEN_MESS_4, "Failed Decompression but Decrypted ");
parser.Reset();
while (file.Read(&buffer, 1) == 1)
{
T_TokenID currentToken = (T_TokenID)parser.CheckForToken(buffer);
switch ( currentToken )
{
case NO_TOKEN:
break;
case TOKEN_DATA_FILE:
{
CString objectStr("Data File M: ");
CString objectFDD("Failed Decryption & Decompression Message");
CString objectFDBD("Failed Decryption but Decompressed Message");
CString objectFDD2("Failed Decompression & Decryption Message");
CString objectFDBD2("Failed Decompression but Decrypted Message");
while (file.Read(&buffer, 1) == 1 && buffer != '\n')
{
objectStr += buffer;
}
if(objectStr.GetLength() > 95) {
m_lst_itemsInFile.AddString(objectStr);
}
/*
}
break;
case TOKEN_SECOND:
{
CString objectStr("File Copy Failed on Data File ");
while (file.Read(&buffer, 1) == 1 && buffer != '\n')
{
objectStr += buffer;
}
m_lst_itemsInFile.AddString(objectStr);
}
break;
/* case TOKEN_DATA_M:
{
CString objectStr("M:");
while (file.Read(&buffer, 1) == 1 && buffer != '\n')
{
objectStr += buffer;
file.Write(&buffer, 1);
}
m_lst_itemsInFile.AddString(objectStr);
}
break;*/
default:
{
ASSERT(false); // CheckForToken(buffer) should always return a valid T_TokenType
return false;
}
} // switch ( CheckForToken(buffer) )
}
file.Close();
return true;
}
Any help would be greatly appreciated.
|
|
|
|
|
Nevermind - got it figured out!
|
|
|
|
|
Hi!
I have made a ActiveX control in Visual C++.
This control should get files from a http server.
My ActiveX control is integrate in a Internet explorer window.
I want to use same Internet session in my control as the internet explorer window.
This because I use a securitybox to connect the https server in the explorer window.
I must have a logged on session in my control
//Thanks
|
|
|
|
|
Like some of the professional software , i plan to create an Uninstall Shortcut in the program files dir of my project. I am using InstallShield to create the shortcuts , but I dont know the shortcut information for the Uinstaller .
By default I have an Uninst.isu which is being used by some Exe i am not aware of .
My idea of creating an Uinstall shortcut would be to create a Shortcut for the "unknown" exe that accepts my Uninst.isu as a parameter !
is this methodology right ? Does anyone know the details of the Unknown exe ?
|
|
|
|
|
I am trying to change the compiler that VC++ .NET uses so I can connect to a database, but I can't find where the compiler is set. Could someone tell me how to change the compiler?
Thanks,
Joel L.
|
|
|
|
|
Is there a known bug with CString's find. I read a file into a CString and then used CString::find to locate some escape characters (MyText.Find("\n", start_loc) ). I tried the version without the starting location and it seems to work fine. However, the version with the starting loction returns a negative one. Is there a problem with the member function or am I just using it wrong??
|
|
|
|
|
Be careful of how you use the second parameter, the starting location. MSDN defines this as
nStart
The index of the character in the string to begin the search with, or 0 to start from the beginning. The character at nStart is excluded from the search if nStart is not equal to 0.
This implies that for a string value of :
<br />
CString strValue("0123456");<br />
int nPos = strValue.Find('3',3);<br />
..This will fail to find the '3', as the starting location is excluded from the search (apart from location zero.
I Dream of Absolute Zero
|
|
|
|