Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add cjk module state pointer to MultibyteCodec struct
Lifetime should be guaranteed, since each MultibyteCodecObjects owns a
reference the cjk codec module that owns the memory of the
MultibyteCodec struct.
  • Loading branch information
erlend-aasland committed Apr 26, 2023
commit 409bf98b512488540c09a180a77d264a44577dfc
11 changes: 7 additions & 4 deletions Modules/cjkcodecs/cjkcodecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct pair_encodemap {
DBCHAR code;
};

typedef struct {
typedef struct _cjk_mod_state {
int num_mappings;
int num_codecs;
struct dbcs_map *mapping_list;
Expand Down Expand Up @@ -271,9 +271,12 @@ add_codecs(cjkcodecs_module_state *st) \
#define CODEC_STATELESS_WINIT(enc) \
NEXT_CODEC = (MultibyteCodec){#enc, NULL, enc##_codec_init, _STATELESS_METHODS(enc)};

#define END_CODECS_LIST \
assert(st->num_codecs == idx); \
return 0; \
#define END_CODECS_LIST \
assert(st->num_codecs == idx); \
for (int i = 0; i < st->num_codecs; i++) { \
st->codec_list[i].modstate = st; \
} \
return 0; \
}


Expand Down
2 changes: 2 additions & 0 deletions Modules/cjkcodecs/multibytecodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef struct {
unsigned char c[8];
} MultibyteCodec_State;

struct _cjk_mod_state;
struct _multibyte_codec;

typedef int (*mbcodec_init)(const struct _multibyte_codec *codec);
Expand Down Expand Up @@ -60,6 +61,7 @@ typedef struct _multibyte_codec {
mbdecode_func decode;
mbdecodeinit_func decinit;
mbdecodereset_func decreset;
struct _cjk_mod_state *modstate;
} MultibyteCodec;

typedef struct {
Expand Down