diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-04-19 19:25:04 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-04-19 19:25:04 (GMT) |
commit | c177597d6da5dedb32aa176e8370db8ffb7f87aa (patch) | |
tree | 26f7eb2702ba4aa3dfd7267d74fe78ad79791a8c /src/analysis/db/misc/rlestr.h | |
parent | 35f37c72e9d81e478395914da6c10b3c546761a7 (diff) |
Handled static strings as well as dynamic strings in comments.
Diffstat (limited to 'src/analysis/db/misc/rlestr.h')
-rw-r--r-- | src/analysis/db/misc/rlestr.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/analysis/db/misc/rlestr.h b/src/analysis/db/misc/rlestr.h index be76f17..82a7d8c 100644 --- a/src/analysis/db/misc/rlestr.h +++ b/src/analysis/db/misc/rlestr.h @@ -38,18 +38,28 @@ /* Informations de base pour tout élément ajouté */ typedef struct _rle_string { - char *data; /* Chaîne de caractères */ - uint32_t length; /* Taille de la chaîne */ + union + { + char *data; /* Chaîne de caractères */ + const char *cst_data; /* Autre version de chaîne */ + }; + + uint16_t length; /* Taille de la chaîne */ + bool dynamic; /* Type d'allocation utilisée */ } rle_string; /* Définit une représentation de chaîne de caractères. */ -void init_rle_string(rle_string *, const char *); +void init_dynamic_rle_string(rle_string *, char *); + +/* Définit une représentation de chaîne de caractères constante. */ +void init_static_rle_string(rle_string *, const char *); -#define exit_rle_string(rle) /* TODO */ +/* Copie une chaîne de caractères existante. */ +void dup_into_rle_string(rle_string *, const char *); -#define dup_rle_string(dst, src) init_rle_string(dst, (src)->data); +#define exit_rle_string(rle) unset_rle_string(rle) #define get_rle_string(rle) (rle)->data @@ -58,7 +68,10 @@ void init_rle_string(rle_string *, const char *); #define is_rle_string_empty(rle) ((rle)->data == NULL) /* Constitue une représentation de chaîne de caractères. */ -void set_rle_string(rle_string *, const char *); +void set_dynamic_rle_string(rle_string *, char *); + +/* Constitue une représentation de chaîne de caractères stable. */ +void set_static_rle_string(rle_string *, const char *); /* Libère la mémoire associée à la représentation. */ void unset_rle_string(rle_string *); |