Annotation of qemu/roms/SLOF/clients/net-snk/libc/sbrk.c, revision 1.1.1.1

1.1       root        1: /******************************************************************************
                      2:  * Copyright (c) 2004, 2008 IBM Corporation
                      3:  * All rights reserved.
                      4:  * This program and the accompanying materials
                      5:  * are made available under the terms of the BSD License
                      6:  * which accompanies this distribution, and is available at
                      7:  * http://www.opensource.org/licenses/bsd-license.php
                      8:  *
                      9:  * Contributors:
                     10:  *     IBM Corporation - initial implementation
                     11:  *****************************************************************************/
                     12: 
                     13: #define HEAP_SIZE 0x200000
                     14: 
                     15: 
                     16: static char heap[HEAP_SIZE];
                     17: static char *actptr;
                     18: 
                     19: void *sbrk(int increment)
                     20: {
                     21:        char *oldptr;
                     22: 
                     23:        /* Called for the first time? Then init the actual pointer */
                     24:        if (!actptr) {
                     25:                actptr = heap;
                     26:        }
                     27: 
                     28:        if (actptr + increment > heap + HEAP_SIZE) {
                     29:                /* Out of memory */
                     30:                return (void *)-1;
                     31:        }
                     32: 
                     33:        oldptr = actptr;
                     34:        actptr += increment;
                     35: 
                     36:        return oldptr;
                     37: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.