Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Manoj Kumar Rai

@Manoj Kumar Rai
About
Posts
93
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to Remove duplicate files rapidly?
    M Manoj Kumar Rai

    I agree one can have mupltiple type of algorithms based on suitability: 1. check for size if does not matches then those files are not same. 2. Compare 2% character from begining and then from end if those does not matches then files are not same. 3. Finally it can be once option to simply compare the remaining part of both files or use CRC, checksum, MD SHA. If MD and SHA or not already calculated and stored then those will be a bit costly.

    Manoj Never Gives up

    Algorithms algorithms cryptography performance tutorial question

  • Memory leak with CString
    M Manoj Kumar Rai

    Thanks Jochen for your inputs. 1. I have used CriticalSection while accessing m_cstrLogLine but have omitted those additional lines to focus on actual business logic. 2. I agree that WideCharToMultiByte() could have been a better option to convert string but I have changed code to rule out any leak during conversion itself. 3. The CopyLogToFileByThread() is not modifying string and thats why its surprising to have memory leak from that function. 4. One more point i will like to mention here is thhat this application has been built for WinCE 6.0. I am trying to replicate the same issue with a test application and if possible for XP.

    Manoj Never Gives up

    C / C++ / MFC performance help

  • Memory leak with CString
    M Manoj Kumar Rai

    I have found a very interesting incident of memory leak in my code. Although I have not been able to find the root cause of the leak still thought to share with you all. I will really appreciate any help on this. I am rather curious to know how come a memory leak can be seen in use of CString in such a simple way. Code: We have a thread function:

    UINT __cdecl LogWriteThread(void *pParam)
    {
    CLog* pLog = (CLog*)pParam;
    UNUSED_ALWAYS(pParam);
    try
    {
    pLog->LogWriteFunc();
    }
    .................
    .................
    return 0;
    }

    UINT __cdecl CLog::LogWriteFunc(void *pParam)
    {
    ..........
    CString cstrLogDataBuffer = m_cstrLogLine;
    m_cstrLogLine = _T("");
    CopyLogToFileByThread(cstrLogDataBuffer);
    }

    void CMpmLog::CopyLogToFileByThread(const CString& cstrLogDataBuffer)
    {
    ....................
    const long iLength = cstrLogDataBuffer.GetLength();
    char *pBuffer = new char[iLength + 1];
    for (long iIndex = 0;iIndex < iLength; iIndex++)
    {
    pBuffer[iIndex] = (char)cstrLogDataBuffer.GetAt(iIndex);
    }
    pBuffer[iLength] = '\0';

      const unsigned int uiWriteLen = fwrite((const void \*)pBuffer, sizeof(char),iLength, m\_pofLogStream);
    
      delete\[\] pBuffer;
      ....................
    

    }

    ======================== If I commment call for "CopyLogToFileByThread" in function LogWriteFunc then memory leak goes away. But thats not the solution.

    Manoj Never Gives up

    C / C++ / MFC performance help

  • Passing CString
    M Manoj Kumar Rai

    It depends on few things. Most importantly what bussiness logic is there in B. For example suppose B function is responsible to read data from a very large file and you want to return that from B. There are changes that file open error may occure then: int B(CString &out_string) will be best option because of two reasons. 1. The error code can be returned as return parameter 2. You dont need to accumulate the content of file in a local variable which gets added and deleted on stack while transferring that as return value.

    Manoj Never Gives up

    ATL / WTL / STL question

  • convert long-&gt;p[][]
    M Manoj Kumar Rai

    What do you actually want to do here?

    Manoj Never Gives up

    C# tutorial

  • Problem to Dial a number from COM port in C#.Net
    M Manoj Kumar Rai

    As you have said, the nokia modem is connected to USB port. Please make sure that you are using the same port in your application. A common mistake people do is to try to open a COM port #1 or #2 instead of USB one.

    Manoj Never Gives up

    C# csharp help com tutorial question

  • Windows form global object
    M Manoj Kumar Rai

    Create one Singleton class. This should have a member of type "OdbcConnection" The connection to the database should be stablished in the constroctor of this class. This class should have a member function to return the object of type "OdbcConnection".

    Manoj Never Gives up

    C# database help question

  • Is it possible to enable controls on the form from a class.
    M Manoj Kumar Rai

    Yes Yes, You are corrrect. I meant TextBox there.

    Manoj Never Gives up

    C# csharp

  • configuaration file
    M Manoj Kumar Rai

    Web.config This file contains settings specific to an application. It contains configuration settings that the common language runtime reads (such as assembly binding policy, remoting objects, and so on), and settings that the application can read. Machine.config This file contains settings that apply to an entire computer. This file is located in the %runtime install path%\Config directory. Machine.config contains configuration settings for machine-wide assembly binding, built-in remoting channels, and ASP.NET. For more details pls have a look at MSDN

    Manoj Never Gives up

    C# question

  • Is it possible to enable controls on the form from a class.
    M Manoj Kumar Rai

    Even you can use Delegates for Enabling/Disabling controls of the Form. The Delegate will remove the requirement to declare control objects (Text etc) public.

    Manoj Never Gives up

    C# csharp

  • [Message Deleted]
    M Manoj Kumar Rai

    Wow...Its a really very good question !! Keep posting:-)

    Manoj Never Gives up

    C#

  • String Builder
    M Manoj Kumar Rai

    Hi, The Sting class has a function "Split()", which returns array of String after spliting the String on the basis of a char.

    Manoj Never Gives up

    C# help tutorial

  • [Message Deleted]
    M Manoj Kumar Rai

    What I can see here is the design, but where is the code?

    Manoj Never Gives up

    C#

  • Create a telephone directory
    M Manoj Kumar Rai

    Ahhh, Ok. Its record ID and not the ID of the person where I thought wrongly. But in either case for the problem we had to print this Unique key do not have any role to play. We have to sort the list on the basis of the Name and get the values printed.

    Manoj Never Gives up

    C# help tutorial

  • open file which can see inside of it
    M Manoj Kumar Rai

    Use StreamReader object to read the content of the file and display it in a window. Also, please make sure that your file may not only contain text data but it can contain picture etc. Hence, if you want to see the real world inside the file you should reading it in binary format and display the records.

    Manoj Never Gives up

    C# question

  • Create a telephone directory
    M Manoj Kumar Rai

    First of all, the ID cannot be a Primary Key as it will not be unique, since anybody can have more than 1 phones. You can get the list sorted on ID/name of the customer. Once it is sorted it will be esily printed.

    Manoj Never Gives up

    C# help tutorial

  • Validating TextBox
    M Manoj Kumar Rai

    Set the Mask property of the MaskedTextBox as per your requirement and the validaton on inputs will be done automatically. There are few predefined Mask available in the Visual Studio, you can chack if you can utilized any of them.

    Manoj Never Gives up

    C# csharp asp-net regex help tutorial

  • Invisible countdown?
    M Manoj Kumar Rai

    For the very precise intervals you can creat a worker thread and with the help of Thread.Sleep() function you can do the countdown.

    Manoj Never Gives up

    C# tutorial question

  • TCP or HTTP
    M Manoj Kumar Rai

    If you use Socket you get more speed.:-)

    Manoj Never Gives up

    C# csharp performance

  • A typical case about interfaces [modified]
    M Manoj Kumar Rai

    I wrote you code in the previous replies it self. In your case: A aa = new A(); //Cast it to interface Interface1 interface1 = aa; //Now u can call the Function ReturnString1 interface1.ReturnString1(); Also you can write it as: ((Interface1)aa).ReturnString1();

    Manoj Never Gives up

    C# help csharp
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups