Re: gwmem patches
Alexander Malysh <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
this patch is a really trivial one. please try attached patch that should fix this warning. btw. I don't have such warning ;) Thanks, Alex Am 06.04.2009 um 12:44 schrieb Vincent CHAVANIS: > > Did this patch has been tested ? > > > In file included from ./gwlib/gwlib.h:83, > from gw/msg.h:69, > from gw/sms.h:89, > from gw/sms.c:65: > ./gwlib/gwmem.h:188:1: warning: "strdup" redefined > In file included from /usr/include/string.h:423, > from ./gwlib/gwlib.h:72, > from gw/msg.h:69, > from gw/sms.h:89, > from gw/sms.c:65: > /usr/include/bits/string2.h:1316:1: warning: this is the location of > the previous definition > > > Vincent. > > > Alexander Malysh a écrit : >> Hi again, >> patch commited to cvs. >> Thanks, >> Alex >> Am 06.04.2009 um 10:56 schrieb Nikos Balkanas: >>> Hi, >>> Here it goes. gw_calloc + gw_strdup. >>> BR, >>> Nikos >>> >>> ----- Original Message ----- >>> *From:* Alexander Malysh <mailto:[email protected]> >>> *To:* Andreas Fink <mailto:[email protected]> >>> *Cc:* Nikos Balkanas >>> <mailto:[email protected]> ; [email protected] >>> <mailto:[email protected]> >>> *Sent:* Monday, April 06, 2009 10:26 AM >>> *Subject:* Re: gwmem patches >>> >>> Hi Nikos, >>> >>> we have at least one +1 so please repost your patch. >>> >>> Thanks, >>> Alex >>> >>> Am 03.04.2009 um 17:37 schrieb Andreas Fink: >>> >>>> I'm +1 on gw_calloc. There's a few times I would have used it in >>>> the past so its nice to have it in gwlib. >>>> >>>> I see very little optimisation of strdup except we do a strlen >>>> twice (once explicit in the malloc line an done implicity in the >>>> strcpy) but it is never bad to save a few microseconds.. (who >>>> knows one might call this one a gazillion times...). so +1 for >>>> that one too. >>>> >>>> >>>> On 02.04.2009, at 23:21, Alexander Malysh wrote: >>>> >>>>> Hi, >>>>> >>>>> thanks for your patch but: >>>>> >>>>> 1) thread.h patch was wrong. I fixed it in CVS. >>>>> 2) gw_strdup optimisation looks OK, please submit as extra >>>>> patch >>>>> 3) gw_calloc, hmm... I don't really see any advantage of this >>>>> one. because >>>>> x = gw_malloc(count*size); >>>>> memset(x, 0); >>>>> do the same. why do we need this? >>>>> >>>>> Thanks, >>>>> Alex >>>>> >>>>> Am 02.04.2009 um 19:09 schrieb Nikos Balkanas: >>>>> >>>>>> Hi, >>>>>> An assortment of small patches to make >>>>>> check_memory_leaks work >>>>>> better: >>>>>> 1) Added support for gw_calloc, which is #undefed but >>>>>> not defined >>>>>> 2) Replaced strcpy with memcpy in gw_strdup for better >>>>>> efficiency >>>>>> 3) Added function prototype in thread.h for >>>>>> mutex_make_measured >>>>>> so that MUTEX_STATS compile correctly. >>>>>> Please decide and vote. >>>>>> BR, >>>>>> Nikos<kannel.diff> >>>>> >>>> >>> >>> <kannel.diff> > > -- > Telemaque - 06560 SOPHIA-ANTIPOLIS - (FR) > Service Technique/Reseau - NOC > Direction du Developpement xMS+ > http://www.telemaque.fr/ > [email protected] > Tel : +33 4 92 90 99 84 (fax 9142) > >
gwmem-warning.diff
(application/octet-stream, 678 B)
diff --git a/gwlib/gwmem.h b/gwlib/gwmem.h index 03f6fcd..6302030 100644 --- a/gwlib/gwmem.h +++ b/gwlib/gwmem.h @@ -181,11 +181,18 @@ void gw_check_shutdown(void); * Make sure no-one uses the unwrapped functions by mistake. */ +/* undefine first to avoid compiler warnings about redefines */ +#undef malloc +#undef calloc +#undef realloc +#undef free +#undef strdup + #define malloc(n) do_not_call_malloc_directly #define calloc(a, b) do_not_use_calloc #define realloc(p, n) do_not_call_realloc_directly #define free(p) do_not_call_free_directly -#define strdup(p) do_not_call_strdup_directly +#define strdup(p) do_not_call_strdup_directly #endif