Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/alloc.c

    r6ba0659 r7937abf  
    1111// Created On       : Wed Feb  3 07:56:22 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Wed Feb 17 11:43:23 2016
    14 // Update Count     : 40
     13// Last Modified On : Fri Mar 11 17:42:08 2016
     14// Update Count     : 59
    1515//
    1616
     17forall( otype T ) T * malloc( char fill );
     18forall( dtype T ) T *?=?( T **, void * );
     19void *malloc( unsigned long int );
     20#if 0
    1721#include <fstream>
    1822#include <stdlib>
     
    2529int * bar( int * p, int c ) { return p; }
    2630int * baz( int * p, int c ) { return p; }
     31#endif
    2732
    2833int main( void ) {
     34#if 0
    2935    size_t size = 10;
    3036    int * p;
    3137    struct S { int x; double y; } * s;
     38#endif
    3239
     40#if 0
    3341    p = malloc( sizeof(*p) );                                                   // C malloc, type unsafe
    3442        printf( "here1\n" );
     
    3745        printf( "here2\n" );
    3846    free( p );
    39     p = malloc( (char)'\0' );                                                                   // CFA malloc, type safe
     47#endif
     48//    int * p;
     49//    p = malloc( (char)'\0' );                                                                 // CFA malloc, type safe
     50    (int *)malloc( (char)'\0' );                                                                        // CFA malloc, type safe
     51    (void *)malloc( (char)'\0' );                                                                       // CFA malloc, type safe
     52#if 0
    4053        printf( "here3\n" );
    4154    p = malloc( p, 1000 );                                                              // CFA remalloc, type safe
     
    6073        printf( "here9\n" );
    6174    free( p );
    62 #if 0
     75
    6376    float * fp = malloc() + 1;
    6477    fprintf( stderr, "%p %p\n", fp, fp - 1 );
Note: See TracChangeset for help on using the changeset viewer.