Groups | Search | Server Info | Login | Register
Groups > comp.os.os2.programmer.porting > #110
| From | Paul Ratcliffe <abuse@orac12.clara34.co56.uk78> |
|---|---|
| Newsgroups | comp.os.os2.programmer.porting |
| Subject | Re: VirtualAlloc to DosAllocMem |
| Date | 2011-07-08 23:02 +0000 |
| Message-ID | <slrnj1f34j.3nn.abuse@news.pr.network> (permalink) |
| References | <iv5rr7$dqt$1@speranza.aioe.org> <4e176267$0$6545$9b4e6d93@newsspool4.arcor-online.net> |
On Fri, 08 Jul 2011 22:03:12 +0200, Heiko Nitzsche
<hn-expires-27nov11@arcor.de> wrote:
> Well, I'd propose the following:
>
> static inline DWORD protection(bool writable, bool executable)
> {
> return executable ?
> (writable ? (PAG_EXECUTE | PAG_READ | PAG_WRITE) : (PAG_EXECUTE | PAG_READ) :
> (writable ? ( PAG_READ | PAG_WRITE) : PAG_READ);
> }
>
> You could also write it this way:
>
> static inline DWORD protection(bool writable, bool executable)
> {
> DWORD permissions = PAG_READ; // always readable
> if (writable)
> {
> permissions |= PAG_WRITE; // allow writing
> }
> if (executable)
> {
> permissions |= PAG_EXECUTE; // content may be executed
> }
> return permissions;
> }
Strewth, you like typing don't you...
return PAG_READ | (writable ? PAG_WRITE : 0) | (executable ? PAG_EXECUTE : 0);
... but why use 1 line when you can use 10, eh?
i = i + 1; // add one to i
FFS.
Back to comp.os.os2.programmer.porting | Previous | Next — Previous in thread | Next in thread | Find similar
VirtualAlloc to DosAllocMem Dave Yeo <dave.r.yeo@gmail.com> - 2011-07-07 19:59 -0700
Re: VirtualAlloc to DosAllocMem Heiko Nitzsche <hn-expires-27nov11@arcor.de> - 2011-07-08 22:03 +0200
Re: VirtualAlloc to DosAllocMem Heiko Nitzsche <hn-expires-27nov11@arcor.de> - 2011-07-08 22:14 +0200
Re: VirtualAlloc to DosAllocMem Dave Yeo <dave.r.yeo@gmail.com> - 2011-07-08 19:39 -0700
Re: VirtualAlloc to DosAllocMem Dave Yeo <dave.r.yeo@gmail.com> - 2011-07-08 21:57 -0700
Re: VirtualAlloc to DosAllocMem Paul Ratcliffe <abuse@orac12.clara34.co56.uk78> - 2011-07-08 23:02 +0000
Re: VirtualAlloc to DosAllocMem "Lars Erdmann" <lars.erdmann@arcor.de> - 2011-07-09 03:46 +0200
Re: VirtualAlloc to DosAllocMem Paul Ratcliffe <abuse@orac12.clara34.co56.uk78> - 2011-07-09 11:32 +0000
Re: VirtualAlloc to DosAllocMem Paul Smedley <paulDESPAM@DESPAMMsmedley.id.au> - 2011-07-10 11:39 +0930
csiph-web