OSDN Git Service

mac: avoid NULL-deref-on-OOM and an error-path leak
[android-x86/external-parted.git] / libparted / labels / pt-common.h
1 /* Factor some of the duplication out of *.c.  */
2
3 #ifdef DISCOVER_ONLY
4 # define NULL_IF_DISCOVER_ONLY(val) NULL
5 #else
6 # define NULL_IF_DISCOVER_ONLY(val) val
7 #endif
8
9 #define PT_define_limit_functions(PT_type)                      \
10                                                                 \
11 static bool                                                     \
12 PT_type##_partition_check (const PedPartition *part)            \
13 {                                                               \
14   return ptt_partition_max_start_len (#PT_type, part);          \
15 }                                                               \
16                                                                 \
17 static PedSector                                                \
18 PT_type##_partition_max_start_sector (void)                     \
19 {                                                               \
20   PedSector max;                                                \
21   int err = ptt_partition_max_start_sector (#PT_type, &max);    \
22   PED_ASSERT (err == 0);                                        \
23   return max;                                                   \
24 }                                                               \
25                                                                 \
26 static PedSector                                                \
27 PT_type##_partition_max_length (void)                           \
28 {                                                               \
29   PedSector max;                                                \
30   int err = ptt_partition_max_length (#PT_type, &max);          \
31   PED_ASSERT (err == 0);                                        \
32   return max;                                                   \
33 }
34
35 #define PT_op_function_initializers(PT_type)                    \
36 probe:                        PT_type##_probe,                  \
37 alloc:                        PT_type##_alloc,                  \
38 duplicate:                    PT_type##_duplicate,              \
39 free:                         PT_type##_free,                   \
40 read:                         PT_type##_read,                   \
41 partition_new:                PT_type##_partition_new,          \
42 partition_duplicate:          PT_type##_partition_duplicate,    \
43 partition_set_flag:           PT_type##_partition_set_flag,     \
44 partition_get_flag:           PT_type##_partition_get_flag,     \
45 partition_set_system:         PT_type##_partition_set_system,   \
46 partition_is_flag_available:  PT_type##_partition_is_flag_available, \
47 partition_align:              PT_type##_partition_align,        \
48 partition_destroy:            PT_type##_partition_destroy,      \
49 partition_enumerate:          PT_type##_partition_enumerate,    \
50 alloc_metadata:               PT_type##_alloc_metadata,         \
51 get_max_primary_partition_count: PT_type##_get_max_primary_partition_count, \
52 get_max_supported_partition_count:PT_type##_get_max_supported_partition_count,\
53 partition_check:              PT_type##_partition_check,        \
54 max_length:                   PT_type##_partition_max_length,   \
55 max_start_sector:             PT_type##_partition_max_start_sector