Ticket #1857 (closed defect: fixed)
fixing some g_malloc callsNreturn
Reported by: | vit_r | Owned by: | andrew_b |
---|---|---|---|
Priority: | major | Milestone: | 4.7.0 |
Component: | mc-core | Version: | 4.7.0-pre4 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | Votes for changeset: |
Description (last modified by andrew_b) (diff)
It's only pointing to start with.
For check of all calls MC-style-guider is wanted.
Attachments
Change History
comment:1 follow-up: ↓ 2 Changed 15 years ago by andrew_b
- Description modified (diff)
g_malloc() never returns NULL and aborts program on failure. g_try_malloc() should be used instead.
comment:2 in reply to: ↑ 1 Changed 15 years ago by vit_r
Replying to andrew_b:
g_malloc() never ...
Great lesson !
Thanks !
Please, what about g_malloc-calls:
mc_search_t *lc_mc_search; lc_mc_search = g_malloc0 (sizeof (*lc_mc_search));
g_malloc-call allows declaration 'mc_search_t *lc_mc_search; ' to be cganged
'lc_mc_search = g_malloc0 (sizeof (*lc_mc_search));' will remain the same
And in next case(from MC)
mc_search_t *lc_mc_search; lc_mc_search = g_malloc0 (sizeof (mc_search_t));
both lines should be edited
To leave similar cases as they are now ?
comment:3 Changed 15 years ago by vit_r
Logicall design:
if [ g_Xalloc(which failing does _NOT_ return NULL) ]; then
If (retval _IS_ checked); then
g_Xalloc is replaced by g_try_Xalloc(failing returns NULL)
fi
elif [ Xalloc(failing returns NULL) ]; then
If (retval is _NOT_ checked); then
Xalloc is replaced by g_Xalloc(failing aborts)
fi
fi
Changed 15 years ago by vit_r
- Attachment 1857-fixing-some-mem_alloc-calls.patch added
For this patch is ctreated new ticket #1863
comment:6 in reply to: ↑ 4 Changed 15 years ago by vit_r
Replying to andrew_b:
Why? What reason for that?
Because this 1857-fixing-some-g_malloc-callsNreturn.patch is wrong
As there is no possibility to remove one file then please remove 1857 ticket
If i could rename the file i would replace it then rename.
Why file can _NOT_ be deleted ? Quit strange..
Sorry for problems
comment:7 Changed 15 years ago by andrew_b
- Status changed from new to accepted
- Owner changed from vit_r to andrew_b
Applied in #1845.