btf.c (9b031c86506cef9acae45e61339fcf9deaabb793) | btf.c (50450fc716c1a570ee8d8bfe198ef5d3cfca36e4) |
---|---|
1// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 2/* Copyright (c) 2018 Facebook */ 3 4#include <endian.h> 5#include <stdio.h> 6#include <stdlib.h> 7#include <string.h> 8#include <fcntl.h> --- 372 unchanged lines hidden (view full) --- 381 return i; 382 } 383 384 return -ENOENT; 385} 386 387void btf__free(struct btf *btf) 388{ | 1// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 2/* Copyright (c) 2018 Facebook */ 3 4#include <endian.h> 5#include <stdio.h> 6#include <stdlib.h> 7#include <string.h> 8#include <fcntl.h> --- 372 unchanged lines hidden (view full) --- 381 return i; 382 } 383 384 return -ENOENT; 385} 386 387void btf__free(struct btf *btf) 388{ |
389 if (!btf) | 389 if (IS_ERR_OR_NULL(btf)) |
390 return; 391 | 390 return; 391 |
392 if (btf->fd != -1) | 392 if (btf->fd >= 0) |
393 close(btf->fd); 394 395 free(btf->data); 396 free(btf->types); 397 free(btf); 398} 399 | 393 close(btf->fd); 394 395 free(btf->data); 396 free(btf->types); 397 free(btf); 398} 399 |
400struct btf *btf__new(__u8 *data, __u32 size) | 400struct btf *btf__new(const void *data, __u32 size) |
401{ 402 struct btf *btf; 403 int err; 404 405 btf = calloc(1, sizeof(struct btf)); 406 if (!btf) 407 return ERR_PTR(-ENOMEM); 408 --- 286 unchanged lines hidden (view full) --- 695 return err; 696} 697 698int btf__fd(const struct btf *btf) 699{ 700 return btf->fd; 701} 702 | 401{ 402 struct btf *btf; 403 int err; 404 405 btf = calloc(1, sizeof(struct btf)); 406 if (!btf) 407 return ERR_PTR(-ENOMEM); 408 --- 286 unchanged lines hidden (view full) --- 695 return err; 696} 697 698int btf__fd(const struct btf *btf) 699{ 700 return btf->fd; 701} 702 |
703void btf__set_fd(struct btf *btf, int fd) 704{ 705 btf->fd = fd; 706} 707 |
|
703const void *btf__get_raw_data(const struct btf *btf, __u32 *size) 704{ 705 *size = btf->data_size; 706 return btf->data; 707} 708 709const char *btf__name_by_offset(const struct btf *btf, __u32 offset) 710{ --- 304 unchanged lines hidden (view full) --- 1015 return -EINVAL; 1016 } 1017 1018 return 0; 1019} 1020 1021void btf_ext__free(struct btf_ext *btf_ext) 1022{ | 708const void *btf__get_raw_data(const struct btf *btf, __u32 *size) 709{ 710 *size = btf->data_size; 711 return btf->data; 712} 713 714const char *btf__name_by_offset(const struct btf *btf, __u32 offset) 715{ --- 304 unchanged lines hidden (view full) --- 1020 return -EINVAL; 1021 } 1022 1023 return 0; 1024} 1025 1026void btf_ext__free(struct btf_ext *btf_ext) 1027{ |
1023 if (!btf_ext) | 1028 if (IS_ERR_OR_NULL(btf_ext)) |
1024 return; 1025 free(btf_ext->data); 1026 free(btf_ext); 1027} 1028 1029struct btf_ext *btf_ext__new(__u8 *data, __u32 size) 1030{ 1031 struct btf_ext *btf_ext; --- 2002 unchanged lines hidden --- | 1029 return; 1030 free(btf_ext->data); 1031 free(btf_ext); 1032} 1033 1034struct btf_ext *btf_ext__new(__u8 *data, __u32 size) 1035{ 1036 struct btf_ext *btf_ext; --- 2002 unchanged lines hidden --- |