diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-11-26 15:55:38 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-12-21 14:54:13 +0100 |
commit | 11f3b9a535ced87882a9792b01b3b7800d355482 (patch) | |
tree | 7e641e16744706f9d72a411e775429a30a7b02e5 /bsps/sparc/shared/1553/gr1553bc.c | |
parent | spcxx01: Add test case (diff) | |
download | rtems-11f3b9a535ced87882a9792b01b3b7800d355482.tar.bz2 |
bsps/sparc: Add grlib_malloc(), grlib_calloc()
This avoids a dependency to errno in device driver code.
Diffstat (limited to '')
-rw-r--r-- | bsps/sparc/shared/1553/gr1553bc.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/bsps/sparc/shared/1553/gr1553bc.c b/bsps/sparc/shared/1553/gr1553bc.c index 099976f958..c7faba436d 100644 --- a/bsps/sparc/shared/1553/gr1553bc.c +++ b/bsps/sparc/shared/1553/gr1553bc.c @@ -90,14 +90,13 @@ struct gr1553bc_list_cfg gr1553bc_def_cfg = int gr1553bc_list_alloc(struct gr1553bc_list **list, int max_major) { - int size; + size_t size; struct gr1553bc_list *l; - size = sizeof(struct gr1553bc_list) + max_major * sizeof(void *); - l = malloc(size); + size = sizeof(*l) + max_major * sizeof(void *); + l = grlib_calloc(1, size); if ( l == NULL ) return -1; - memset(l, 0, size); l->major_cnt = max_major; *list = l; @@ -310,7 +309,7 @@ int gr1553bc_list_table_alloc } else { if (bdtab_custom == NULL) { /* Allocate descriptors */ - list->_table = malloc(size + (GR1553BC_BD_ALIGN-1)); + list->_table = grlib_malloc(size + (GR1553BC_BD_ALIGN-1)); if ( list->_table == NULL ) return -1; } else { @@ -508,15 +507,16 @@ int gr1553bc_major_alloc_skel { struct gr1553bc_major *maj; struct gr1553bc_minor *minor; - int size, i; + size_t size; + int i; if ( (cfg == NULL) || (major == NULL) || (cfg->minor_cnt <= 0) ) return -1; /* Allocate Major Frame description, but no descriptors */ - size = sizeof(struct gr1553bc_major) + cfg->minor_cnt * - (sizeof(struct gr1553bc_minor) + sizeof(void *)); - maj = (struct gr1553bc_major *)malloc(size); + size = sizeof(*maj) + cfg->minor_cnt * + (sizeof(*minor) + sizeof(void *)); + maj = grlib_malloc(size); if ( maj == NULL ) return -1; @@ -1248,14 +1248,13 @@ void *gr1553bc_open(int minor) if ( pdev == NULL ) goto fail; - irq_log_p = malloc(GR1553BC_IRQLOG_SIZE*2); + irq_log_p = grlib_malloc(GR1553BC_IRQLOG_SIZE*2); if ( irq_log_p == NULL ) goto fail; - priv = malloc(sizeof(struct gr1553bc_priv)); + priv = grlib_calloc(1, sizeof(*priv)); if ( priv == NULL ) goto fail; - memset(priv, 0, sizeof(struct gr1553bc_priv)); /* Init BC device */ priv->pdev = pdev; |