Просмотр исходного кода

Using long for file size in MG_OPEN_FILE ev_data

Sergey Lyubka 12 лет назад
Родитель
Сommit
365b5e8f8a
2 измененных файлов с 3 добавлено и 3 удалено
  1. 1 1
      mongoose.c
  2. 2 2
      mongoose.h

+ 1 - 1
mongoose.c

@@ -526,7 +526,7 @@ static int is_file_in_memory(struct mg_connection *conn, const char *path,
                              struct file *filep) {
   conn->request_info.ev_data = (void *) path;
   if ((filep->membuf = call_user(conn, MG_OPEN_FILE)) != NULL) {
-    filep->size = (int) (long) conn->request_info.ev_data;
+    filep->size = (long) conn->request_info.ev_data;
   }
   return filep->membuf != NULL;
 }

+ 2 - 2
mongoose.h

@@ -87,11 +87,11 @@ enum mg_event {
   // will use the returned value as a pointer to the file data. This allows
   // for example to serve files from memory.
   // ev_data contains file path, including document root path.
-  // Upon return, ev_data should return file size,  which should be an int.
+  // Upon return, ev_data should return file size,  which should be a long int.
   //
   //   const char *file_name = request_info->ev_data;
   //   if (strcmp(file_name, "foo.txt") == 0) {
-  //     request_info->ev_data = (void *) (int) 4;
+  //     request_info->ev_data = (void *) (long) 4;
   //     return "data";
   //   }
   //   return NULL;