Re: [Warzone-dev] More patches for warnings

2006-11-03 Thread Gerard Krol

Dennis Schridde wrote:

Am Donnerstag, 2. November 2006 22:27 schrieb Troman:
  

- Original Message -
From: Dennis Schridde [EMAIL PROTECTED]
To: Development list warzone-dev@gna.org
Sent: Wednesday, November 01, 2006 11:50 PM
Subject: Re: [Warzone-dev] More patches for warnings
Am Mittwoch, 1. November 2006 23:03 schrieb Gerard Krol:
  

Hi,

This evenings work ;)

new.patch contains the addition of two macro's, and the use of them to
replace MALLOC


MALLOC itself is a macro around some custom wrapper around malloc...
So perhaps we should also check if we (additionally to using this NEW
wrapper)
could drop that MALLOC malloc wrapper...
(I don't really know what exact functionality MALLOC and FREE provide,
besides
that FREE checks for NULL pointers, what is useless as free() is defined
by the C std to do nothing in that case.)

--Dennis

PS: Idea seems good, didn't look at the patch.
  

It is a cleaner approach, but for me it is more intuitively to use MALLOC
since already the name implies that malloc functionality will be used at
some point. And these 2 new macros will not replace all occurances of
MALLOC, so we are just introducing more macros for the same functionality.

But anyway, I will be an impartial executor of a collective opinion. To
make it painless for everyone if no objections will be raised until
tomorrow evening I will just go on and apply the patch.


Well, then make it MALLOC instead. NEW is also more C++ style...
I'd be ok with it, but it doesn't bring much real benefit, though you could 
even don't use NEW. Also most ppl would probably not use NEW anyway as they 
are used to MALLOC/malloc and that's what's used in most of the code.
You are right YaWM (Yet another Wrapper Macro) is probably not needed and 
would clutter the code even more.
  
I have a lot more experience using the C++ new than the C malloc, as you 
guessed, so the new seems more natural to me.
And how about calling it MALLOC_NEW? It is indeed YaWM, but it saves a 
cast and a sizeof.
And I find (SOME_LONG_TYPENAME*)MALLOC(sizeof(SOME_LONG_TYPENAME)*a*b) 
not so nice to look at as

MALLOC_NEW_ARRAY(SOME_LONG_TYPENAME, a*b)
But I guess the former is more C.
If someone wonders what this macro does, he can take an easy look at mem.h
Shall I try to completely remove all MALLOC calls and replace them with 
MALLOC_NEW?
The MALLOC calls left are for strings and texture pages and such, but 
they can then be replaced with:

MALLOC_NEW_ARRAY(char, size)

The alternative is that I add casts to all MALLOC's that not yet have 
them, this would fix a lot of warnings too.


- Gerard

___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev


Re: [Warzone-dev] STRING - char

2006-11-03 Thread Dennis Schridde
Am Freitag, 3. November 2006 16:05 schrieb Gerard Krol:
 Hi,

 from lib/framework/types.h:
 typedef char STRING; // Should be removed...

 I had some fun running sed, and replaced all occurences of STRING with
 char.
A while ago I tried this as well. Nice. :)


pgpHmWGIXGT9o.pgp
Description: PGP signature
___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev


Re: [Warzone-dev] More patches for warnings

2006-11-03 Thread Troman


- Original Message - 
From: Gerard Krol [EMAIL PROTECTED]

To: Development list warzone-dev@gna.org
Sent: Friday, November 03, 2006 12:21 PM
Subject: Re: [Warzone-dev] More patches for warnings


[...]
The alternative is that I add casts to all MALLOC's that not yet have 
them, this would fix a lot of warnings too.


- Gerard


Maybe this is a better alternative to using NEW as an additional marco? 
Whether to get rid of MALLOC in favor or malloc or something else is another 
question, although judging from what Per said it will probably take a bit 
more effort to do this.


Anyway, delaying the commit until we clarify this.

Troman 



___
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev