Request for Review: 5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion

Martin Buchholz martinrb at google.com
Thu Dec 20 04:32:45 UTC 2012


+    res = readFully (fdin, &magic, sizeof(magic));
+    if (res != 4 || magic != magicNumber()) {

s/4/sizeof(magic)/

---

+extern int errno;

Delete.

---

+#define ALLOC(X,Y) { \
+    void *mptr; \
+    mptr = malloc (Y); \
+    if (mptr == 0) { \
+        error (fdout, ERR_MALLOC); \
+    } \
+    X = mptr; \
+}

It's traditional to define such a thing as a real function instead of a
macro, often with the name xmalloc.

Compare with

static void*
xmalloc(JNIEnv *env, size_t size)
{
    void *p = malloc(size);
    if (p == NULL)
        JNU_ThrowOutOfMemoryError(env, NULL);
    return p;
}

#define NEW(type, n) ((type *) xmalloc(env, (n) * sizeof(type)))



More information about the build-dev mailing list