Skip to content

Instantly share code, notes, and snippets.

@Mach12
Last active October 7, 2015 08:47
Show Gist options
  • Select an option

  • Save Mach12/7cafe77a7c9eba159345 to your computer and use it in GitHub Desktop.

Select an option

Save Mach12/7cafe77a7c9eba159345 to your computer and use it in GitHub Desktop.

Revisions

  1. Mach12 revised this gist Oct 7, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pootis.c
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ int main()
    int someArray[10];
    int* somePointer = malloc( sizeof(int) * 10 );

    // Changer la taille et somePointer
    // Changer la taille de somePointer
    somePointer = realloc(somePointer, sizeof(int) * 15);

    // Ca c'est valide:
  2. Mach12 created this gist Oct 7, 2015.
    19 changes: 19 additions & 0 deletions pootis.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #include <stdlib>

    int main()
    {
    // Exactement la même chose
    // sauf que le 2e est alloué
    int someArray[10];
    int* somePointer = malloc( sizeof(int) * 10 );

    // Changer la taille et somePointer
    somePointer = realloc(somePointer, sizeof(int) * 15);

    // Ca c'est valide:
    someArray[8] = 2;
    // Et ça aussi
    somePointer[12] = 15;

    return EXIT_SUCCESS;
    }