All pastes #52878 Raw Edit

Miscellany

public text v1 · immutable
#52878 ·published 2006-05-02 13:44 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE (10 * 1024 * 1024)

int
main()
{
        int counter = 0;
        for ( ; ; ) {
                void *p = malloc(SIZE);
                if (!p) {
                        printf("Cannot allocate more memory\n");
                        return (0);
                }
                memset(p, 0, SIZE);
                counter += SIZE;
                printf("Allocated %d bytes\n", counter);
        }
        return (0);
}