]> git.sesse.net Git - vlc/commitdiff
Reduce memory usage (-28%) by packing index structures.
authorLaurent Aimar <fenrir@videolan.org>
Mon, 17 Nov 2008 18:55:01 +0000 (19:55 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 17 Nov 2008 19:03:29 +0000 (20:03 +0100)
It is done by using __attribute__((__packed__)) when available.

src/input/es_out_timeshift.c

index 818c02164ac7076617c0e095765498563fbaca60..d26441a67ce2f401bdcf120c30210835c1e9b711 100644 (file)
  * Local prototypes
  *****************************************************************************/
 
+/* XXX attribute_packed is (and MUST be) used ONLY to reduce memory usage */
+#ifdef HAVE_ATTRIBUTE_PACKED
+#   define attribute_packed __attribute__((__packed__))
+#else
+#   define attribute_packed
+#endif
+
 enum
 {
     C_ADD,
@@ -61,25 +68,25 @@ enum
     C_CONTROL,
 };
 
-typedef struct
+typedef struct attribute_packed
 {
     es_out_id_t *p_es;
     es_format_t *p_fmt;
 } ts_cmd_add_t;
 
-typedef struct
+typedef struct attribute_packed
 {
     es_out_id_t *p_es;
 } ts_cmd_del_t;
 
-typedef struct
+typedef struct attribute_packed
 {
     es_out_id_t *p_es;
     block_t *p_block;
-    off_t i_offset;
+    int     i_offset;  /* We do not use file > INT_MAX */
 } ts_cmd_send_t;
 
-typedef struct
+typedef struct attribute_packed
 {
     int  i_query;
 
@@ -117,9 +124,9 @@ typedef struct
     };
 } ts_cmd_control_t;
 
-typedef struct
+typedef struct attribute_packed
 {
-    int     i_type;
+    int8_t  i_type;
     mtime_t i_date;
     union
     {
@@ -137,7 +144,7 @@ struct ts_storage_t
 
     /* */
     char    *psz_file;  /* Filename */
-    int64_t i_file_max; /* Max size in bytes */
+    size_t  i_file_max; /* Max size in bytes */
     int64_t i_file_size;/* Current size in bytes */
     FILE    *p_filew;   /* FILE handle for data writing */
     FILE    *p_filer;   /* FILE handle for data reading */
@@ -319,6 +326,16 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out
     p_sys->psz_tmp_path = GetTmpPath( psz_tmp_path );
     msg_Dbg( p_input, "using timeshift  path '%s'", p_sys->psz_tmp_path );
 
+#if 0
+#define S(t) msg_Err( p_input, "SIZEOF("#t")=%d", sizeof(t) )
+    S(ts_cmd_t);
+    S(ts_cmd_control_t);
+    S(ts_cmd_send_t);
+    S(ts_cmd_del_t);
+    S(ts_cmd_add_t);
+#undef S
+#endif
+
     return p_out;
 }