Skip to content
Snippets Groups Projects
Select Git revision
  • 65eec2b982e055a7b0cef577bdada56b8cc402cd
  • master default
2 results

dragon.c

Blame
  • user avatar
    vht24 authored
    65eec2b9
    History
    dragon.c 802 B
    #include <stdio.h>
    #include <stdlib.h>
    #include <zlib.h>
    #include "dragon_data.h"  // Include the embedded binary data
    
    #define DRAGON_BUFFER_SIZE 100000
    
    // EXTRA CREDIT - print the Drexel dragon from embedded binary
    extern void print_dragon() {
        unsigned char *decompressed_data = (unsigned char *)malloc(DRAGON_BUFFER_SIZE);
        if (!decompressed_data) {
            fprintf(stderr, "Memory allocation failed!\n");
            return;
        }
    
        uLongf decompressed_size = DRAGON_BUFFER_SIZE;
        
        // Ensure correct decompression
        if (uncompress(decompressed_data, &decompressed_size, DRAGON_BIN, DRAGON_BIN_SIZE) != Z_OK) {
            fprintf(stderr, "Decompression fail\n");
            free(decompressed_data);
            return;
        }
    
        printf("%s", decompressed_data);
        free(decompressed_data);
    }