Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Created August 22, 2024 21:19

Revisions

  1. mortymacs created this gist Aug 22, 2024.
    20 changes: 20 additions & 0 deletions main.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    void action(char *a, char *b) __attribute__((nonnull(2)));

    void action(char *a, char *b) {
    if (a != NULL) {
    printf("%s\n", a);
    }
    printf("%s\n", b);
    }

    int main() {
    char *a = (char *)malloc(sizeof(char) + 1);
    strcpy(a, "t");
    action(a, a);
    action(NULL, a);
    action(a, NULL);
    }