[Home]

Summary:ASTERISK-09579: [patch] Don't use malloc() & memset(), instead use ast_calloc() and ast_malloc().
Reporter:Eliel Sardanons (eliel)Labels:
Date Opened:2007-06-03 17:58:58Date Closed:2007-06-06 16:20:41
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Resources/res_jabber
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) apps.patch
( 1) cdr.patch
( 2) channels.patch
( 3) codecs.patch
( 4) funcs.patch
( 5) main.patch
( 6) res_jabber.c.patch
( 7) res.patch
Description:Code cleanup. (There is a bug related to res_jabber, this patch does not solve any issue).

replace malloc() & memset() -> ast_calloc()
replace malloc -> ast_malloc()
Comments:By: Tilghman Lesher (tilghman) 2007-06-04 10:28:47

Two more changes need to be made:

1) When using sizeof() to reference a struct, we prefer that you use the pointer notation, i.e. foo = ast_calloc(1, sizeof(*foo))

2) All invocations of free() should be changed to ast_free().  While this is merely a cosmetic change right now, we may add additional debugging to this routine in the future.

By: Eliel Sardanons (eliel) 2007-06-04 11:54:18

Ok, I will add your changes and make another .patch

By: Eliel Sardanons (eliel) 2007-06-04 11:57:32

You want me to take this just in res_jabber, or in all the asterisk source and commit a patch for every file?

By: Tilghman Lesher (tilghman) 2007-06-04 12:18:18

We'd prefer one large patch containing all of the files you're going to touch, rather than individual patches for each file.

By: Eliel Sardanons (eliel) 2007-06-04 19:37:09

I will update one patch file for each directory. I think is better than having one patch for ALL the files..

By: Eliel Sardanons (eliel) 2007-06-04 21:11:16

In channels.patch you will find some bugs solved in chan_mgcp and chan_misdn.

By: Eliel Sardanons (eliel) 2007-06-04 22:57:05

in app_voicemail fix a minor issue (delete a not needed free).

By: Eliel Sardanons (eliel) 2007-06-04 23:21:08

I think thats all. I didn't change astmm.c (the free()'s there). And the other changes I made (apart from free()s and malloc()/calloc()) were all reported in the bugnotes.

By: snuffy (snuffy) 2007-06-05 00:58:12

Nice work eliel,
I was going to attempt but thought i'd screw it up :)

By: Eliel Sardanons (eliel) 2007-06-05 08:59:56

Corydon76: We could add to ast_free() a log when trying to free a NULL pointer, this is not an issue, but when we try to free a NULL pointer is because something else maybe wrong, so it's a good starting point for finding bugs...

By: Jason Parker (jparker) 2007-06-05 18:27:47

Part of what needs to be done with this janitor project, is also remove the "Out of memory!" messages, as the ast_*alloc() functions do that already.

By: Eliel Sardanons (eliel) 2007-06-05 19:00:45

I recommend commiting this patch's and then while I countinue changing code, because it will be so big and so many files to be changed that it will conflict with everything!. I will continue working... but is my suggestion.

By: Tilghman Lesher (tilghman) 2007-06-06 16:20:41

Committed, revision 67864.