---
name: "msr_init"
section: "3"
platform: "linux"
package: "libmseed-doc"
version: "2.19.8-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/msr_init"
---

# msr\_init(3)

Initializing and freeing MSRecord and related structures

## NAME

msr\_init - Initializing and freeing MSRecord and related structures

## SYNOPSIS

```
#include <libmseed.h>
MSRecord *msr_init ( MSRecord *msr );
void      msr_free ( MSRecord **ppmsr );
void      msr_free_blktchain ( MSRecord *msr );
```

## DESCRIPTION

**msr\_init** will initialize a MSRecord structure.  If the *msr* parameter is NULL a new structure will be allocated.  If the *msr* parameter is not NULL the blockette chain (MSRecord.blkts) will be freed but any memory allocated for MSRecord.fsdh and MSRecord.datasamples will be preserved as it will cleanly be re-used by routines such as **[msr\_unpack(3)](/msr_unpack/3.md)**.

**msr\_free** will free all memory associated with a MSRecord structure including the blockette chain and set the structure pointer (\*ppmsr) to 0.

**msr\_free\_blktchain** will free all memory associated with the blockette chain of an MSRecord structure.  The shortcut blockette pointers will also be reset.

## RETURN VALUES

**msr\_init** returns a pointer to the MSRecord structure initialized on success or NULL on error.

## SEE ALSO

**[ms\_intro(3)](/ms_intro/3.md)**, **[msr\_pack(3)](/msr_pack/3.md)** and **[msr\_unpack(3)](/msr_unpack/3.md)**.

## AUTHOR

```
Chad Trabant
IRIS Data Management Center
```
