Parcourir la source

libdpkg: Add new m_strndup()

Guillem Jover il y a 14 ans
Parent
commit
d09cc13711
2 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 1 0
      lib/dpkg/dpkg.h
  2. 6 0
      lib/dpkg/mlib.c

+ 1 - 0
lib/dpkg/dpkg.h

@@ -134,6 +134,7 @@ void setcloexec(int fd, const char* fn);
 void *m_malloc(size_t);
 void *m_realloc(void*, size_t);
 char *m_strdup(const char *str);
+char *m_strndup(const char *str, size_t n);
 int m_asprintf(char **strp, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
 void m_dup2(int oldfd, int newfd);
 void m_pipe(int fds[2]);

+ 6 - 0
lib/dpkg/mlib.c

@@ -67,6 +67,12 @@ m_strdup(const char *str)
   return must_alloc(strdup(str));
 }
 
+char *
+m_strndup(const char *str, size_t n)
+{
+  return must_alloc(strndup(str, n));
+}
+
 int
 m_asprintf(char **strp, const char *fmt, ...)
 {