---
name: "duplocale"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/duplocale"
---

# duplocale(3)

duplicate an locale

## NAME

**duplocale** – duplicate an locale

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<locale.h\>**

*locale\_t*\

**duplocale**(*locale\_t locale*);

## DESCRIPTION

Duplicates an existing *locale\_t* returning a new *locale\_t* that refers to the same locale values but has an independent internal state. Various functions, such as [mblen(3)](/mblen/3.md) require a persistent state. These functions formerly used static variables and calls to them from multiple threads had undefined behavior. They now use fields in the *locale\_t* associated with the current thread by [uselocale(3)](/uselocale/3.md). These calls are therefore only thread safe on threads with a unique per-thread locale. The locale returned by this call must be freed with [freelocale(3)](/freelocale/3.md).

## SEE ALSO

[freelocale(3)](/freelocale/3.md), [localeconv(3)](/localeconv/3.md), [newlocale(3)](/newlocale/3.md), [querylocale(3)](/querylocale/3.md), [uselocale(3)](/uselocale/3.md), [xlocale(3)](/xlocale/3.md)

## STANDARDS

This function conforms to IEEE Std 1003.1-2008 (“POSIX.1”).

## BUGS

Ideally, [uselocale(3)](/uselocale/3.md) should make a copy of the *locale\_t* implicitly to ensure thread safety, and a copy of the global locale should be installed lazily on each thread. The FreeBSD implementation does not do this, for compatibility with Darwin.
