Skip to content

Commit f59d5aa

Browse files
authored
refactor(lib): mark pointers as const where possible (unicorn-engine#2140)
1 parent bc73cb2 commit f59d5aa

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

include/unicorn/unicorn.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ uc_err uc_reg_read2(uc_engine *uc, int regid, void *value, size_t *size);
848848
invalid
849849
*/
850850
UNICORN_EXPORT
851-
uc_err uc_reg_write_batch(uc_engine *uc, int *regs, void *const *vals,
851+
uc_err uc_reg_write_batch(uc_engine *uc, int const *regs, void *const *vals,
852852
int count);
853853

854854
/*
@@ -863,7 +863,8 @@ uc_err uc_reg_write_batch(uc_engine *uc, int *regs, void *const *vals,
863863
invalid
864864
*/
865865
UNICORN_EXPORT
866-
uc_err uc_reg_read_batch(uc_engine *uc, int *regs, void **vals, int count);
866+
uc_err uc_reg_read_batch(uc_engine *uc, int const *regs, void **vals,
867+
int count);
867868

868869
/*
869870
Write multiple register values.
@@ -879,8 +880,8 @@ uc_err uc_reg_read_batch(uc_engine *uc, int *regs, void **vals, int count);
879880
corresponding register.
880881
*/
881882
UNICORN_EXPORT
882-
uc_err uc_reg_write_batch2(uc_engine *uc, int *regs, const void *const *vals,
883-
size_t *sizes, int count);
883+
uc_err uc_reg_write_batch2(uc_engine *uc, int const *regs,
884+
const void *const *vals, size_t *sizes, int count);
884885

885886
/*
886887
Read multiple register values.
@@ -897,7 +898,7 @@ uc_err uc_reg_write_batch2(uc_engine *uc, int *regs, const void *const *vals,
897898
corresponding register.
898899
*/
899900
UNICORN_EXPORT
900-
uc_err uc_reg_read_batch2(uc_engine *uc, int *regs, void *const *vals,
901+
uc_err uc_reg_read_batch2(uc_engine *uc, int const *regs, void *const *vals,
901902
size_t *sizes, int count);
902903

903904
/*
@@ -1278,8 +1279,8 @@ uc_err uc_context_reg_read2(uc_context *ctx, int regid, void *value,
12781279
for detailed error).
12791280
*/
12801281
UNICORN_EXPORT
1281-
uc_err uc_context_reg_write_batch(uc_context *ctx, int *regs, void *const *vals,
1282-
int count);
1282+
uc_err uc_context_reg_write_batch(uc_context *ctx, int const *regs,
1283+
void *const *vals, int count);
12831284

12841285
/*
12851286
Read multiple register values from a context.
@@ -1293,7 +1294,7 @@ uc_err uc_context_reg_write_batch(uc_context *ctx, int *regs, void *const *vals,
12931294
for detailed error).
12941295
*/
12951296
UNICORN_EXPORT
1296-
uc_err uc_context_reg_read_batch(uc_context *ctx, int *regs, void **vals,
1297+
uc_err uc_context_reg_read_batch(uc_context *ctx, int const *regs, void **vals,
12971298
int count);
12981299

12991300
/*
@@ -1310,7 +1311,7 @@ uc_err uc_context_reg_read_batch(uc_context *ctx, int *regs, void **vals,
13101311
corresponding register.
13111312
*/
13121313
UNICORN_EXPORT
1313-
uc_err uc_context_reg_write_batch2(uc_context *ctx, int *regs,
1314+
uc_err uc_context_reg_write_batch2(uc_context *ctx, int const *regs,
13141315
const void *const *vals, size_t *sizes,
13151316
int count);
13161317

@@ -1329,8 +1330,8 @@ uc_err uc_context_reg_write_batch2(uc_context *ctx, int *regs,
13291330
corresponding register.
13301331
*/
13311332
UNICORN_EXPORT
1332-
uc_err uc_context_reg_read_batch2(uc_context *ctx, int *regs, void *const *vals,
1333-
size_t *sizes, int count);
1333+
uc_err uc_context_reg_read_batch2(uc_context *ctx, int const *regs,
1334+
void *const *vals, size_t *sizes, int count);
13341335

13351336
/*
13361337
Restore the current CPU context from a saved copy.

uc.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ uc_err uc_close(uc_engine *uc)
572572
}
573573

574574
UNICORN_EXPORT
575-
uc_err uc_reg_read_batch(uc_engine *uc, int *regs, void **vals, int count)
575+
uc_err uc_reg_read_batch(uc_engine *uc, int const *regs, void **vals, int count)
576576
{
577577
UC_INIT(uc);
578578
reg_read_t reg_read = uc->reg_read;
@@ -596,7 +596,7 @@ uc_err uc_reg_read_batch(uc_engine *uc, int *regs, void **vals, int count)
596596
}
597597

598598
UNICORN_EXPORT
599-
uc_err uc_reg_write_batch(uc_engine *uc, int *regs, void *const *vals,
599+
uc_err uc_reg_write_batch(uc_engine *uc, int const *regs, void *const *vals,
600600
int count)
601601
{
602602
UC_INIT(uc);
@@ -627,7 +627,7 @@ uc_err uc_reg_write_batch(uc_engine *uc, int *regs, void *const *vals,
627627
}
628628

629629
UNICORN_EXPORT
630-
uc_err uc_reg_read_batch2(uc_engine *uc, int *regs, void *const *vals,
630+
uc_err uc_reg_read_batch2(uc_engine *uc, int const *regs, void *const *vals,
631631
size_t *sizes, int count)
632632
{
633633
UC_INIT(uc);
@@ -651,8 +651,8 @@ uc_err uc_reg_read_batch2(uc_engine *uc, int *regs, void *const *vals,
651651
}
652652

653653
UNICORN_EXPORT
654-
uc_err uc_reg_write_batch2(uc_engine *uc, int *regs, const void *const *vals,
655-
size_t *sizes, int count)
654+
uc_err uc_reg_write_batch2(uc_engine *uc, int const *regs,
655+
const void *const *vals, size_t *sizes, int count)
656656
{
657657
UC_INIT(uc);
658658
reg_write_t reg_write = uc->reg_write;
@@ -2344,8 +2344,8 @@ uc_err uc_context_reg_read2(uc_context *ctx, int regid, void *value,
23442344
}
23452345

23462346
UNICORN_EXPORT
2347-
uc_err uc_context_reg_write_batch(uc_context *ctx, int *regs, void *const *vals,
2348-
int count)
2347+
uc_err uc_context_reg_write_batch(uc_context *ctx, int const *regs,
2348+
void *const *vals, int count)
23492349
{
23502350
reg_write_t reg_write = find_context_reg_rw(ctx->arch, ctx->mode).write;
23512351
void *env = ctx->data;
@@ -2367,7 +2367,7 @@ uc_err uc_context_reg_write_batch(uc_context *ctx, int *regs, void *const *vals,
23672367
}
23682368

23692369
UNICORN_EXPORT
2370-
uc_err uc_context_reg_read_batch(uc_context *ctx, int *regs, void **vals,
2370+
uc_err uc_context_reg_read_batch(uc_context *ctx, int const *regs, void **vals,
23712371
int count)
23722372
{
23732373
reg_read_t reg_read = find_context_reg_rw(ctx->arch, ctx->mode).read;
@@ -2389,7 +2389,7 @@ uc_err uc_context_reg_read_batch(uc_context *ctx, int *regs, void **vals,
23892389
}
23902390

23912391
UNICORN_EXPORT
2392-
uc_err uc_context_reg_write_batch2(uc_context *ctx, int *regs,
2392+
uc_err uc_context_reg_write_batch2(uc_context *ctx, int const *regs,
23932393
const void *const *vals, size_t *sizes,
23942394
int count)
23952395
{
@@ -2412,8 +2412,8 @@ uc_err uc_context_reg_write_batch2(uc_context *ctx, int *regs,
24122412
}
24132413

24142414
UNICORN_EXPORT
2415-
uc_err uc_context_reg_read_batch2(uc_context *ctx, int *regs, void *const *vals,
2416-
size_t *sizes, int count)
2415+
uc_err uc_context_reg_read_batch2(uc_context *ctx, int const *regs,
2416+
void *const *vals, size_t *sizes, int count)
24172417
{
24182418
reg_read_t reg_read = find_context_reg_rw(ctx->arch, ctx->mode).read;
24192419
void *env = ctx->data;

0 commit comments

Comments
 (0)