Skip to content

Commit

Permalink
Use pointer-to-struct typedefs for pointer-to-struct types
Browse files Browse the repository at this point in the history
Use of void * can lead to silent errors if you accidentally pass
the address of a pointer instead of the pointer.

I got the struct names from the API docs, although having those
match is not actually important.

This now matches the pattern used in the official headers.
  • Loading branch information
philipl committed Sep 16, 2019
1 parent 4094cc6 commit 9fdaf11
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions include/ffnvcodec/dynlink_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,23 @@
#define CU_CTX_SCHED_BLOCKING_SYNC 4

typedef int CUdevice;
typedef void* CUarray;
typedef void* CUcontext;
typedef void* CUstream;
typedef void* CUevent;
typedef void* CUfunction;
typedef void* CUmodule;
typedef void* CUtexObject;
typedef void* CUmipmappedArray;
typedef void* CUgraphicsResource;
typedef void* CUexternalMemory;
typedef void* CUexternalSemaphore;
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) || defined(__LP64__)
typedef unsigned long long CUdeviceptr;
#else
typedef unsigned int CUdeviceptr;
#endif
typedef unsigned long long CUtexObject;

typedef struct CUarray_st *CUarray;
typedef struct CUctx_st *CUcontext;
typedef struct CUstream_st *CUstream;
typedef struct CUevent_st *CUevent;
typedef struct CUfunc_st *CUfunction;
typedef struct CUmod_st *CUmodule;
typedef struct CUmipmappedArray_st *CUmipmappedArray;
typedef struct CUgraphicsResource_st *CUgraphicsResource;
typedef struct CUextMemory_st *CUexternalMemory;
typedef struct CUextSemaphore_st *CUexternalSemaphore;

typedef enum cudaError_enum {
CUDA_SUCCESS = 0,
Expand Down

0 comments on commit 9fdaf11

Please sign in to comment.