Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

imalloc

Name: Anonymous 2012-04-26 15:58

/*
 *    Non-failing allocation routines (init cannot fail).
 */
static
void *imalloc(size_t size)
{
    void    *m;

    while ((m = malloc(size)) == NULL) {
        initlog(L_VB, "out of memory");
        do_sleep(5);
    }
    memset(m, 0, size);
    return m;
}

Name: Anonymous 2012-04-26 16:00

use C#

Name: Anonymous 2012-04-26 17:01

just use an assert, you'll never see OOM

Name: Anonymous 2012-04-26 17:22

>>3
OOM is like that beast from X-Files s5e19

Name: Anonymous 2012-04-26 18:41

>>3-4
I have OOM errors regularly. 1Gio RAM and no swap ; shit's no fun.

Name: Anonymous 2012-04-26 19:05

The name is misleading, it should be icalloc and not imalloc.

Name: Anonymous 2012-04-26 23:33

ikellogg()

Name: Anonymous 2012-04-27 0:09

When reality runs out of memory locally, you get black hole expansion.

Name: Anonymous 2012-04-27 14:44

Either download more memory, or allocate everything statically. initab is never that complex that you would run out of static structures. Better still, just use the loaded file as storage. And just train those processes to behave better instead of hogging all your memory.

Name: Anonymous 2012-04-27 15:29

/*
 *    OOPS: segmentation violation!
 *    If we have the info, print where it occured.
 *    Then sleep 30 seconds and try to continue.
 */
static
#if defined(STACK_DEBUG) && defined(__linux__)
# ifdef __GNUC__
void segv_handler(int sig __attribute__((unused)), struct sigcontext ctx)
# else
void segv_handler(int sig, struct sigcontext ctx)
# endif
{
    char    *p = "";
    int    saved_errno = errno;

    if ((void *)ctx.eip >= (void *)do_sleep &&
        (void *)ctx.eip < (void *)main)
        p = " (code)";
    initlog(L_VB, "PANIC: segmentation violation at %p%s! "
          "sleeping for 30 seconds.", (void *)ctx.eip, p);
    coredump();
    do_sleep(30);
    errno = saved_errno;
}
#else
# ifdef __GNUC__
void segv_handler(int sig __attribute__((unused)))
# else
void segv_handler(int sig)
# endif
{
    int    saved_errno = errno;

    initlog(L_VB,
        "PANIC: segmentation violation! sleeping for 30 seconds.");
    coredump();
    do_sleep(30);
    errno = saved_errno;
}
#endif

Name: Anonymous 2012-04-27 15:45

Name: Anonymous 2012-04-27 18:39

>>10
Should change to POSIX signal handlers.

Name: bampu pantsu 2012-05-29 4:39

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List