diff options
author | Kevin Newton <[email protected]> | 2023-09-27 12:24:48 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2023-09-27 13:57:38 -0400 |
commit | 4f73a7c2f7ff16aa78cf0dec2d4c7f90a2c41c9b (patch) | |
tree | 3b6f0cedc858d46d30a28c6d03439d653884a915 /prism/util/pm_string.h | |
parent | 8ab56869a64fdccc094f4a83c6367fb23b72d38b (diff) |
Sync to prism rename commits
Diffstat (limited to 'prism/util/pm_string.h')
-rw-r--r-- | prism/util/pm_string.h | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/prism/util/pm_string.h b/prism/util/pm_string.h index bcdf8b66d9..acc0fa5277 100644 --- a/prism/util/pm_string.h +++ b/prism/util/pm_string.h @@ -1,7 +1,7 @@ -#ifndef YARP_STRING_H -#define YARP_STRING_H +#ifndef PRISM_STRING_H +#define PRISM_STRING_H -#include "yarp/defines.h" +#include "prism/defines.h" #include <assert.h> #include <stdbool.h> @@ -11,51 +11,51 @@ // This struct represents a string value. typedef struct { - enum { YP_STRING_SHARED, YP_STRING_OWNED, YP_STRING_CONSTANT, YP_STRING_MAPPED } type; + enum { PM_STRING_SHARED, PM_STRING_OWNED, PM_STRING_CONSTANT, PM_STRING_MAPPED } type; const uint8_t *source; size_t length; -} yp_string_t; +} pm_string_t; -#define YP_EMPTY_STRING ((yp_string_t) { .type = YP_STRING_CONSTANT, .source = NULL, .length = 0 }) +#define PM_EMPTY_STRING ((pm_string_t) { .type = PM_STRING_CONSTANT, .source = NULL, .length = 0 }) // Initialize a shared string that is based on initial input. -void yp_string_shared_init(yp_string_t *string, const uint8_t *start, const uint8_t *end); +void pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end); // Initialize an owned string that is responsible for freeing allocated memory. -void yp_string_owned_init(yp_string_t *string, uint8_t *source, size_t length); +void pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length); // Initialize a constant string that doesn't own its memory source. -void yp_string_constant_init(yp_string_t *string, const char *source, size_t length); +void pm_string_constant_init(pm_string_t *string, const char *source, size_t length); // Read the file indicated by the filepath parameter into source and load its -// contents and size into the given yp_string_t. -// The given yp_string_t should be freed using yp_string_free() when it is no longer used. +// contents and size into the given pm_string_t. +// The given pm_string_t should be freed using pm_string_free() when it is no longer used. // // We want to use demand paging as much as possible in order to avoid having to // read the entire file into memory (which could be detrimental to performance // for large files). This means that if we're on windows we'll use // `MapViewOfFile`, on POSIX systems that have access to `mmap` we'll use // `mmap`, and on other POSIX systems we'll use `read`. -YP_EXPORTED_FUNCTION bool yp_string_mapped_init(yp_string_t *string, const char *filepath); +PRISM_EXPORTED_FUNCTION bool pm_string_mapped_init(pm_string_t *string, const char *filepath); // Returns the memory size associated with the string. -size_t yp_string_memsize(const yp_string_t *string); +size_t pm_string_memsize(const pm_string_t *string); // Ensure the string is owned. If it is not, then reinitialize it as owned and // copy over the previous source. -void yp_string_ensure_owned(yp_string_t *string); +void pm_string_ensure_owned(pm_string_t *string); // Returns the length associated with the string. -YP_EXPORTED_FUNCTION size_t yp_string_length(const yp_string_t *string); +PRISM_EXPORTED_FUNCTION size_t pm_string_length(const pm_string_t *string); // Returns the start pointer associated with the string. -YP_EXPORTED_FUNCTION const uint8_t * yp_string_source(const yp_string_t *string); +PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source(const pm_string_t *string); // Free the associated memory of the given string. -YP_EXPORTED_FUNCTION void yp_string_free(yp_string_t *string); +PRISM_EXPORTED_FUNCTION void pm_string_free(pm_string_t *string); -// Returns the size of the yp_string_t struct. This is necessary to allocate the +// Returns the size of the pm_string_t struct. This is necessary to allocate the // correct amount of memory in the FFI backend. -YP_EXPORTED_FUNCTION size_t yp_string_sizeof(void); +PRISM_EXPORTED_FUNCTION size_t pm_string_sizeof(void); -#endif // YARP_STRING_H +#endif // PRISM_STRING_H |