Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct {
- uint16_t index;
- uint8_t tok;
- uint8_t blen;
- } record_info_t;
- typedef struct {
- uint16_t index;
- unsigned int n_records;
- record_info_t *records;
- } disc_info_t;
- /* Are the following two code snippets doing the same thing? I seem to be losing data using smart pointers and think maybe the push_back isn't copying deep enough, or something along those lines. */
- disc_info_t *discs = new disc_info_t[disc_map->size()];
- size_t i = 0;
- for (auto& [index, disc] : *disc_map)
- discs[i++] = disc;
- ---
- std::shared_ptr<std::vector<disc_info_t>> discs =
- std::make_shared<std::vector<disc_info_t>>(disc_map->size());
- // is this losing data?j specifically, records within discs?
- for (auto& [index, disc] : *disc_map)
- discs->push_back(disc);
Advertisement
Add Comment
Please, Sign In to add comment