Skip to content

Commit 21717fc

Browse files
authored
Removes unnecessary member taken_ownership_of_bu (#431)
The process is completely linear independant of failure, hence it can safely be removed.
1 parent 3c7c9d3 commit 21717fc

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

lib/src/sv_bu_list.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ bu_list_item_create(const bu_info_t *bu)
9494
}
9595

9696
item->bu = (bu_info_t *)bu;
97-
item->taken_ownership_of_bu = false;
9897
item->validation_status = get_validation_status_from_bu(bu);
9998
item->tmp_validation_status = item->validation_status;
10099

@@ -111,13 +110,11 @@ bu_list_item_free(bu_list_item_t *item)
111110
}
112111

113112
// If we have |bu| data we free the temporarily used TLV memory slot.
114-
if (item->taken_ownership_of_bu) {
115-
if (item->bu) {
116-
free(item->bu->nalu_data_wo_epb);
117-
free(item->bu->pending_bu_data);
118-
}
119-
free(item->bu);
113+
if (item->bu) {
114+
free(item->bu->nalu_data_wo_epb);
115+
free(item->bu->pending_bu_data);
120116
}
117+
free(item->bu);
121118
free(item);
122119
}
123120

@@ -161,7 +158,6 @@ bu_list_item_print(const bu_list_item_t *item)
161158
// bu_info_t *bu;
162159
// char validation_status;
163160
// uint8_t hash[MAX_HASH_SIZE];
164-
// bool taken_ownership_of_bu;
165161
// bool has_been_decoded;
166162
// bool used_in_gop_hash;
167163

@@ -176,8 +172,7 @@ bu_list_item_print(const bu_list_item_t *item)
176172
memcpy(validation_status_str, &item->tmp_validation_status, 1);
177173

178174
printf("BU type = %s\n", bu_type_str);
179-
printf("validation_status = %s%s%s%s\n", validation_status_str,
180-
(item->taken_ownership_of_bu ? ", taken_ownership_of_bu" : ""),
175+
printf("validation_status = %s%s%s\n", validation_status_str,
181176
(item->has_been_decoded ? ", has_been_decoded" : ""),
182177
(item->used_in_gop_hash ? ", used_in_gop_hash" : ""));
183178
sv_print_hex_data(item->hash, item->hash_size, "item->hash ");
@@ -395,16 +390,7 @@ bu_list_copy_last_item(bu_list_t *list, bool hash_algo_known)
395390
}
396391
SV_DONE(status)
397392

398-
if (item->taken_ownership_of_bu) {
399-
// We have taken ownership of the existing |bu|, hence we need to free it when releasing it.
400-
// NOTE: This should not happen if the list is used properly.
401-
if (item->bu) {
402-
free(item->bu->nalu_data_wo_epb);
403-
}
404-
free(item->bu);
405-
}
406393
item->bu = copied_bu;
407-
item->taken_ownership_of_bu = true;
408394

409395
return status;
410396
}

lib/src/sv_internal.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,8 @@ struct _bu_list_item_t {
174174
uint8_t hash[MAX_HASH_SIZE]; // The hash of the BU is stored in this memory slot, if it
175175
// is hashable that is.
176176
size_t hash_size;
177-
// Flags
178-
bool taken_ownership_of_bu; // Flag to indicate if the item has taken ownership of the
179-
// |bu| memory, hence need to free the memory if the item is released.
180177

178+
// Flags
181179
bool has_been_decoded; // Marks a SEI as decoded. Decoding it twice might overwrite
182180
// vital information.
183181
bool used_in_gop_hash; // Marks the BU as being part of a computed |gop_hash|.

0 commit comments

Comments
 (0)