Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
dbmalloc1.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "nspr.h"

Go to the source code of this file.

Functions

void r1 (void)
void r2 (void)
int main (int argc, char *argv[])

Variables

PRIntn failed_already = 0
PRIntn debug_mode
int should_fail = 0
int actually_failed = 0

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 122 of file dbmalloc1.c.

{

 /* main test */
       
    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
    PR_STDIO_INIT();
    r2();

    if(failed_already)    
        return 1;
    else
        return 0;

    
}

Here is the call graph for this function:

void r1 ( void  )

Definition at line 74 of file dbmalloc1.c.

{
    int i;
       actually_failed=0;
    for(  i = 0; i < 5; i++ )
    {
        void *x = PR_MALLOC(128);
        if( (void *)0 == x ) {
                     if (debug_mode) printf("\tMalloc %d failed.\n", i+1);
                     actually_failed = 1;
              }
        PR_DELETE(x);
    }

       if (((should_fail != actually_failed) & (!debug_mode))) failed_already=1;


    return;
}

Here is the caller graph for this function:

void r2 ( void  )

Definition at line 98 of file dbmalloc1.c.

{
    int i;

    for( i = 0; i <= 5; i++ )
    {
              should_fail =0;
        if( 0 == i ) {
                     if (debug_mode) printf("No malloc should fail:\n");
              }
        else {
                     if (debug_mode) printf("Malloc %d should fail:\n", i);
                     should_fail = 1;
              }
        PR_SetMallocCountdown(i);
        r1();
        PR_ClearMallocCountdown();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 69 of file dbmalloc1.c.

PRIntn debug_mode

Definition at line 65 of file dbmalloc1.c.

PRIntn failed_already = 0

Definition at line 64 of file dbmalloc1.c.

Definition at line 68 of file dbmalloc1.c.