---
name: "kstrndup"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/kstrndup"
---

# kstrndup(9)

allocate space for and copy an existing string

## NAME

kstrndup - allocate space for and copy an existing string

## SYNOPSIS

**char \* kstrndup(const char \*** *s***, size\_t** *max***, gfp\_t** *gfp***);**

## ARGUMENTS

*s*

the string to duplicate

*max*

read at most *max* chars from *s*

*gfp*

the GFP mask used in the **kmalloc** call when allocating memory

## NOTE

Use **kmemdup\_nul** instead if the size is known exactly.

## COPYRIGHT
