Ruby: prism/util/pm_memchr.h File Reference

Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)

Functions
pm_memchr.h File Reference

A custom memchr implementation. More...

`#include "prism/defines.h"`
`#include "prism/encoding.h"`
`#include <stddef.h>`

Go to the source code of this file.

## Functions
void * | pm_memchr (const void *source, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding)
| We need to roll our own memchr to handle cases where the encoding changes and we need to search for a character in a buffer that could be the trailing byte of a multibyte character.

## Detailed Description

A custom memchr implementation.

Definition in file pm_memchr.h.

## Function Documentation

## ◆ pm_memchr()

void * pm_memchr | ( | const void * | source,
|  | int | character,
|  | size_t | number,
|  | bool | encoding_changed,
|  | const pm_encoding_t * | encoding )

We need to roll our own memchr to handle cases where the encoding changes and we need to search for a character in a buffer that could be the trailing byte of a multibyte character.

Parameters

  source | The source string.
  character | The character to search for.
  number | The maximum number of bytes to search.
  encoding_changed | Whether the encoding changed.
  encoding | A pointer to the encoding.

Returns
  A pointer to the first occurrence of the character in the source string, or NULL if no such character exists.

Definition at line 11 of file pm_memchr.c.