Dear all,
im porting a WIN APP to LINUX, and face some problems that r hard for
me to solve, could u dear guys give me some hands?
i'd like to reimplement the following funcs or replace them with other
ways , but i have no idea how to !!
1. HLOCAL LocalAlloc( UINT uFlags, SIZE_T uBytes)
MSDN: The LocalAlloc function allocates the specified number of bytes
from the heap. Windows memory management does not provide a separate
local heap and global heap.
Also: LocalFree
2. HGLOBAL GlobalAlloc( UINT uFlags, SIZE_T dwBytes)
MSDN: The GlobalAlloc function allocates the specified number of bytes
from the heap. Windows memory management does not provide a separate
local heap and global heap.
Also: GlobalFree, GlobalLock, GlobalUnlock
3. LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize,DWORD
flAllocationType, DWORD flProtect )
MSDN: The VirtualAlloc function reserves or commits a region of pages
in the virtual address space of the calling process. Memory allocated
by this function is automatically initialized to zero, unless MEM_RESET
is specified.
Also: VirtualFree, VirtualLock, VirtualUnlock
4. BOOL AnsiToOem( LPCSTR lpszSrc,LPSTR lpszDst)
MSDN: Converts all the characters in this CStringT object from the ANSI
character set to the OEM character set.
Also: OemToAnsi, AnsiToOemBuff
thx! 7 5017
I can't answer your questions directly, but you might want to
check out the wxwidgets library and see how they did some of
these things.
--
% Randy Yates % "Bird, on the wing,
%% Fuquay-Varina, NC % goes floating by
%%% 919-577-9882 % but there's a teardrop in his eye..."
%%%% <ya***@ieee.org> % 'One Summer Dream', *Face The Music*, ELO http://home.earthlink.net/~yatescr
hey Yates,
i have check thr wxwidgets manual (2.6.1), but found nothing valuable,
:-(
hey Yates,
i have check thr wxwidgets manual (2.6.1), but cant find anything
valuable, :-(
"vansky" <hu*********@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... Dear all,
im porting a WIN APP to LINUX, and face some problems that r hard for me to solve, could u dear guys give me some hands?
i'd like to reimplement the following funcs or replace them with other ways , but i have no idea how to !!
1. HLOCAL LocalAlloc( UINT uFlags, SIZE_T uBytes)
MSDN: The LocalAlloc function allocates the specified number of bytes from the heap. Windows memory management does not provide a separate local heap and global heap.
Also: LocalFree
This sounds like a plain ol' malloc. Although I don't know what flags does.
I think it depends on what kind of operability you're trying to get here.
2. HGLOBAL GlobalAlloc( UINT uFlags, SIZE_T dwBytes)
MSDN: The GlobalAlloc function allocates the specified number of bytes from the heap. Windows memory management does not provide a separate local heap and global heap.
Also: GlobalFree, GlobalLock, GlobalUnlock
I"d probably use the plain ol' malloc here too. Linux has a different
memory model (I believe) so I would let the Linux OS handle it. Unless you
need the specific functionaly this gives you, just use malloc I guess.
AGain, not sure what flags does.
3. LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize,DWORD flAllocationType, DWORD flProtect )
MSDN: The VirtualAlloc function reserves or commits a region of pages in the virtual address space of the calling process. Memory allocated by this function is automatically initialized to zero, unless MEM_RESET is specified.
Also: VirtualFree, VirtualLock, VirtualUnlock
Okay, here you're allocating pages of memory (16k I believe?). If you can't
find anything specific in Linux to do this guess what I would use instead...
yeap, malloc. Again though, you haven't explained what functionality you're
expecting other than allocating memory.
4. BOOL AnsiToOem( LPCSTR lpszSrc,LPSTR lpszDst)
MSDN: Converts all the characters in this CStringT object from the ANSI character set to the OEM character set.
Also: OemToAnsi, AnsiToOemBuff
I have no clue on this one.
Jim Langston wrote: "vansky" <hu*********@hotmail.com> wrote in message news:11**********************@o13g2000cwo.googlegr oups.com... Dear all,
im porting a WIN APP to LINUX, and face some problems that r hard for me to solve, could u dear guys give me some hands?
i'd like to reimplement the following funcs or replace them with other ways , but i have no idea how to !!
1. HLOCAL LocalAlloc( UINT uFlags, SIZE_T uBytes)
MSDN: The LocalAlloc function allocates the specified number of bytes from the heap. Windows memory management does not provide a separate local heap and global heap.
Also: LocalFree
This sounds like a plain ol' malloc. Although I don't know what flags does. I think it depends on what kind of operability you're trying to get here.
2. HGLOBAL GlobalAlloc( UINT uFlags, SIZE_T dwBytes)
MSDN: The GlobalAlloc function allocates the specified number of bytes from the heap. Windows memory management does not provide a separate local heap and global heap.
Also: GlobalFree, GlobalLock, GlobalUnlock
I"d probably use the plain ol' malloc here too. Linux has a different memory model (I believe) so I would let the Linux OS handle it. Unless you need the specific functionaly this gives you, just use malloc I guess. AGain, not sure what flags does.
3. LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize,DWORD flAllocationType, DWORD flProtect )
MSDN: The VirtualAlloc function reserves or commits a region of pages in the virtual address space of the calling process. Memory allocated by this function is automatically initialized to zero, unless MEM_RESET is specified.
Also: VirtualFree, VirtualLock, VirtualUnlock
Okay, here you're allocating pages of memory (16k I believe?). If you can't find anything specific in Linux to do this guess what I would use instead... yeap, malloc. Again though, you haven't explained what functionality you're expecting other than allocating memory.
4. BOOL AnsiToOem( LPCSTR lpszSrc,LPSTR lpszDst)
MSDN: Converts all the characters in this CStringT object from the ANSI character set to the OEM character set.
Also: OemToAnsi, AnsiToOemBuff
I have no clue on this one.
As Jim said, the linux memory model is different from Windows.
You can use malloc(). Of course you can also use 'new' in C++
programs.
you can use calloc() when you need blocks of memory that are
zeroed out.
malloc/calloc/realloc are in stdlib.h (aka cstdlib)
as part of the standard lib.
I have ported several large software suites from Windows
to Linux, and many of the Windows API's are replaced by
a much smaller number of standard and/or linux API's.
In other words, the code usually gets simpler.
Larry
hey Jim & larry,
thanks a lot,
my thoughs r very close to u.
im porting a large SW too, so i have to find the BEST ways, otherwise
ill face some unpredictable results.
gettimeofday(struct timeval *, struct timezone *) to replace
GetTimeZoneInformation
using timezone info, the following funcs can be solved,
LocalFileTimeToFileTime, This function converts a local file time to a
file time based on the Coordinated Universal Time (UTC).
FileTimeToLocalFileTime
that's right? or any better way?
On Fri, 13 Jan 2006 03:31:48 GMT, Larry I Smith
<la***********@verizon.net> wrote: 1. HLOCAL LocalAlloc( UINT uFlags, SIZE_T uBytes) Also: LocalFree 2. HGLOBAL GlobalAlloc( UINT uFlags, SIZE_T dwBytes) Also: GlobalFree, GlobalLock, GlobalUnlock
I believe these are old relics from the 16-bit days when Windows
actually did have a local and global memory model. All your gui
controls where allocated locally, etc. (Well, mixed with GDI resource
memory... yada. )
As Jim said, the linux memory model is different from Windows.
Bigtime. :-)
I have ported several large software suites from Windows to Linux, and many of the Windows API's are replaced by a much smaller number of standard and/or linux API's. In other words, the code usually gets simpler.
I find it "refreshing." Free of all the MicroSkunk extensions and
arcane HANDLES :-) and such. A lot of Windows code is just
plain ugly. ( In more ways than one.) :-)
Behind every great fortune there is a crime.
- Honore de Balzac (1799-1850) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ^CeFoS^ |
last post by:
Hello to everybody,
I've done an application that draws in a frame the trajectory of a
robot. The robot position is readed through the serial port, and
several commands are wrote through the...
|
by: Michael B. Allen |
last post by:
Coming from C and Java on *nix I'm a little out of my element messing around
with CList and MSVC++ but I think my issues are largely syntactic.
I have an ADT that I use called a 'varray' that can...
|
by: Pat |
last post by:
Hi,
1. Any faster method (other than for-loop) to initialize array?
2. Does there have similar C++ function to replace C's "fprintf"?
Thanks.
Pat
|
by: MNQ |
last post by:
Hi All
I want to use my parallel port of my PC to control some external devices. I
am writing a program in ANSI C using the PacificC compiler. What I need to
know is how to access the parallel...
|
by: collinm |
last post by:
hi
we use linux and c language
under bash i do
echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS1
that send command to a led display (alpha sign communication)
|
by: collinm |
last post by:
hi
i send a command to a led display, the led display is suppose to return
me some character
i write a string on a serial port
void ledDisplayExist()
{
char msg={'\0', '\0', '\0', '\0',...
|
by: david.brown.0 |
last post by:
I'm trying to make a Java program access a parallel port. Java's comm
API does not provide me with the control I need. I need to be able to
write to the data and control pins and read the status...
|
by: smnoff |
last post by:
I have searched the internet for malloc and dynamic malloc; however, I still
don't know or readily see what is general way to allocate memory to char *
variable that I want to assign the substring...
|
by: George2 |
last post by:
Hello everyone,
Should I delete memory pointed by pointer a if there is bad_alloc when
allocating memory in memory pointed by pointer b? I am not sure
whether there will be memory leak if I do...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |