Welcome to little lamb

Code » limb » commit 37f2532

Rename encdata() to saencdata()

author Olivier Brunel
2023-02-20 09:11:40 UTC
committer Olivier Brunel
2023-02-20 09:12:00 UTC
parent c1e01865486964045ab4fee1a2d495c03cffb67d

Rename encdata() to saencdata()

Better that way. Also first move into a better/more consistent interface
for limb where (when applicable) we'll put destination first, context
last.

doc/{encdata.3.md => saencdata.3.md} +8 -8
include/limb/encdata.h +0 -9
include/limb/saencdata.h +9 -0
meta/libs/limb +1 -1
src/{encdata.c => saencdata.c} +2 -2

diff --git a/doc/encdata.3.md b/doc/saencdata.3.md
similarity index 56%
rename from doc/encdata.3.md
rename to doc/saencdata.3.md
index 0f0886a..4e1c8f2 100644
--- a/doc/encdata.3.md
+++ b/doc/saencdata.3.md
@@ -1,23 +1,23 @@
 % limb manual
-% encdata(3)
+% saencdata(3)
 
 # NAME
 
-encdata - encode data (integer (u64) or blob (byte array)) into stralloc
+saencdata - encode data (integer (u64) or blob (byte array)) into stralloc
 
 # SYNOPSIS
 
-    #include <limb/encdata.h>
+    #include <limb/saencdata.h>
 
 ```pre hl
-int encdata(const u16 <em>id</em>, const void *<em>val</em>, const size_t <em>size</em>,
-            stralloc *<em>sa</em>)
+int saencdata(stralloc *<em>sa</em>, const u16 <em>id</em>,
+              const void *<em>val</em>, const size_t <em>size</em>)
 ```
 
 # DESCRIPTION
 
-The `encdata`() function will encode the specified `val` into the given stralloc
-`sa` as a byte array that can be stored e.g. in a file.
+The `saencdata`() function will encode into the given stralloc `sa` the
+specified `val` as a byte array that can e.g. be stored in a file.
 
 First the given `id` is stored in little endian. Its most significant bit
 determines what kind of data is pointed to by `val` :
@@ -36,5 +36,5 @@ When encoding an integer (u64), it will be stored via [`u64_pack_trim`](3)
 
 # RETURN VALUE
 
-`encdata`() return 1 on success and 0 on failure, i.e. failure to allocate
+`saencdata`() return 1 on success and 0 on failure, i.e. failure to allocate
 memory within the given `sa`
diff --git a/include/limb/encdata.h b/include/limb/encdata.h
deleted file mode 100644
index 0d7ffba..0000000
--- a/include/limb/encdata.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef LIMB_ENCDATA_h
-#define LIMB_ENCDATA_h
-
-#include <skalibs/stralloc.h>
-#include "limb/int.h"
-
-extern int encdata(const u16 id, const void *val, const size_t size, stralloc *sa);
-
-#endif /* LIMB_ENCDATA_h */
diff --git a/include/limb/saencdata.h b/include/limb/saencdata.h
new file mode 100644
index 0000000..7d3cdd0
--- /dev/null
+++ b/include/limb/saencdata.h
@@ -0,0 +1,9 @@
+#ifndef LIMB_SAENCDATA_h
+#define LIMB_SAENCDATA_h
+
+#include <skalibs/stralloc.h>
+#include "limb/int.h"
+
+extern int saencdata(stralloc *sa, const u16 id, const void *val, const size_t size);
+
+#endif /* LIMB_SAENCDATA_h */
diff --git a/meta/libs/limb b/meta/libs/limb
index f7e49f0..41d77dc 100644
--- a/meta/libs/limb
+++ b/meta/libs/limb
@@ -12,7 +12,7 @@ obj/msb64.o
 obj/uint64_pack_trim.o
 obj/uint64_unpack_trim.o
 # data-encoding (integers or blobs)
-obj/encdata.o
+obj/saencdata.o
 # content-based chunking
 obj/nextsplit_ae.o
 obj/nextsplit_buz.o
diff --git a/src/encdata.c b/src/saencdata.c
similarity index 85%
rename from src/encdata.c
rename to src/saencdata.c
index c8d8282..4fa6a54 100644
--- a/src/encdata.c
+++ b/src/saencdata.c
@@ -1,9 +1,9 @@
-#include "limb/encdata.h"
+#include "limb/saencdata.h"
 #include "limb/u16.h"
 #include "limb/u64.h"
 
 int
-encdata(const u16 id, const void *val, const size_t size, stralloc *sa)
+saencdata(stralloc *sa, const u16 id, const void *val, const size_t size)
 {
     int is_blob = id & 0x8000;
     int salen = sa->len;