# LoadFileHere

Loads a file into a pre-allocated buffer.

### Synopsis

`void * LoadFileHere (char *fname, int32 *pfsize, void *buffer, int32 bufsize)`

### Description

Loads a file into a buffer you allocate. It is identical to `LoadFile()` except that it lets you allocate the buffer. If the bufsize parameter is non-zero, this function checks to ensure that the file will fit in the specified buffer. The actual size of the file, which may be smaller than the buffer, is stored at *pfsize. If an error occurs the word at *pfsize will contain a negative error code.

When allocating a buffer, remember that the buffer has to be an integral multiple of the file device's blocksize.That is, loading a 700 byte file from a CD still requires a 2k buffer. A useful space-saving technique involves loading a small file into the inactive screen buffer in VRAM then copying it (or perhaps just a small portion of it that you need) to a right-sized buffer elsewhere in memory.

### Arguments

fname
  Name of the file to load.

pfsize
  Pointer to a word which, after the call, holds the actual size of the file.

buffer
  Pointer to a buffer large enough to hold the file.

bufsize
  Size of the buffer, or zero to disable overflow checking.

### Return Value

Returns a pointer to the buffer, or NULL on error.

### Implementation

Library call implemented in lib3do.lib.

### Associated Files

lib3do.lib, blockfile.h

### See Also

``LoadFile`,` AsyncLoadFile