Christian Grothoff há 15 anos atrás
pai
commit
b6ed288d26
1 ficheiros alterados com 8 adições e 2 exclusões
  1. 8 2
      src/examples/https_fileserver_example.c

+ 8 - 2
src/examples/https_fileserver_example.c

@@ -105,6 +105,13 @@ file_reader (void *cls, uint64_t pos, char *buf, int max)
   return fread (buf, 1, max, file);
 }
 
+static void
+file_free_callback (void *cls)
+{
+  FILE *file = cls;
+  fclose (file);
+}
+
 /* HTTP access handler call back */
 static int
 http_ahc (void *cls,
@@ -148,8 +155,7 @@ http_ahc (void *cls,
     {
       response = MHD_create_response_from_callback (buf.st_size, 32 * 1024,     /* 32k PAGE_NOT_FOUND size */
                                                     &file_reader, file,
-                                                    (MHD_ContentReaderFreeCallback)
-                                                    & fclose);
+                                                    &file_free_callback);
       if (response == NULL)
 	{
 	  fclose (file);