source: rtems/cpukit/libpci/pci_dev_create.c @ 76b9c31

Last change on this file since 76b9c31 was 76b9c31, checked in by Sebastian Huber <sebastian.huber@…>, on Aug 25, 2017 at 9:01:15 AM

libpci: Use calloc()

Update #2133.

  • Property mode set to 100644
File size: 665 bytes
Line 
1/*  Device allocator helper used by PCI Auto/Read Configuration Library
2 *
3 *  COPYRIGHT (c) 2010 Cobham Gaisler AB.
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#include <rtems.h>
11#include <stdlib.h>
12#include <rtems/bspIo.h>
13
14#include <pci.h>
15#include <pci/cfg.h>
16
17#include "pci_internal.h"
18
19struct pci_dev *pci_dev_create(int isbus)
20{
21        void *ptr;
22        int size;
23
24        if (isbus)
25                size = sizeof(struct pci_bus);
26        else
27                size = sizeof(struct pci_dev);
28
29        ptr = calloc(1, size);
30        if (!ptr)
31                rtems_fatal_error_occurred(RTEMS_NO_MEMORY);
32        return ptr;
33}
Note: See TracBrowser for help on using the repository browser.