Beispiel #1
0
static void *smalloc(size_t size) {
  void *ret;

  ret = malloc(size);
  if (ret == 0)
    ret = null_alloc(size);

  return ret;
}
Beispiel #2
0
static void *smalloc(size_t size) {
  void *res;

  if (size == 0) {
    /* Avoid zero-length malloc(); on non-POSIX systems, the behavior is
     * not dependable.  And on POSIX systems, malloc(3) might still return
     * a "unique pointer" for a zero-length allocation (or NULL).
     *
     * Either way, a zero-length allocation request here means that someone
     * is doing something they should not be doing.
     */
    null_alloc();
  }

  res = malloc(size);
  if (res == NULL) {
    null_alloc();
  }

  return res;
}