~connman-maintainers/connman/head

Viewing all changes in revision 7989.

  • Committer: Daniel Wagner
  • Date: 2020-02-10 08:14:23 UTC
  • Revision ID: git-v1:1223965aa365bc7526caa3c44ac28613bcf0db2b
coding-style: Update M8 about g_malloc use

Document the useles effort to handle small memory allocations. Even
the small test program below shows glibc's malloc wont return a NULL allocation. The
program will be killed by the OOM.

int main(int argc, char *argv[])
{
        while (1) {
                if (!malloc(16))
                        exit(3);
        }
        return 0;
}

$ ./malloc
[1]    25788 killed     ./malloc
$ echo $?
137

[ 2729.844036] Out of memory: Killed process 25745 (malloc) total-vm:15131480kB, anon-rss:14977108kB, file-rss:948kB, shmem-rss:0kB
[ 2730.091798] oom_reaper: reaped process 25745 (malloc), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

Linux userland system programming is different to embedded systems
where any sized malloc can and *will* fail.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: