Skip to content
  • Daniel Kurtz's avatar
    Fix malloc/calloc/free usage · 36c7ca02
    Daniel Kurtz authored
    . Use calloc when allocating objects.
    . Use malloc when allocating a buffer that we are about to completely fill.
    . In both cases, NULL check the result, unless using X built-in "kill server
    on alloc fail" versions (e.g., xnfcalloc())
    . The canonical way to call calloc is:
      ptr = calloc(nelem, sizeof *ptr); /* or sizeof(*ptr) */
      if (ptr) {
          /* Handle OOM */
      }
    
    . Don't NULL check before calling free().
    
    BUG=none
    TEST=compiles clean; sanity check ui on device
    
    (cherry picked from commit 79795728e366a56013aa4affa2d42128441a5eb9)
    From: https://chromium.googlesource.com/chromiumos/third_party/xf86-video-armsoc
    
    Change-Id: I18b6a6c7c173c0120ec6da948b1e55cbe96e1e1d
    36c7ca02