Blame src/arbits/slbt_archive_mapstrv.c

df2627
/*******************************************************************/
df2627
/*  slibtool: a skinny libtool implementation, written in C        */
df2627
/*  Copyright (C) 2016--2024  SysDeer Technologies, LLC            */
df2627
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
df2627
/*******************************************************************/
df2627
df2627
#include <stdlib.h>
df2627
#include <inttypes.h>
df2627
#include <slibtool/slibtool.h>
df2627
#include "slibtool_driver_impl.h"
df2627
#include "slibtool_errinfo_impl.h"
4b56de
#include "slibtool_visibility_impl.h"
df2627
#include "slibtool_ar_impl.h"
df2627
df2627
static int slbt_strcmp(const void * a, const void * b)
df2627
{
df2627
	return strcmp(*(const char **)a,*(const char **)b);
df2627
}
df2627
4b56de
slbt_hidden int slbt_update_mapstrv(
df2627
	const struct slbt_driver_ctx *  dctx,
df2627
	struct slbt_archive_meta_impl * mctx)
df2627
{
df2627
	size_t          nsyms;
df2627
	const char **   symv;
df2627
	const char **   mapstrv;
df2627
df2627
	for (nsyms=0,symv=mctx->symstrv; *symv; symv++)
df2627
		nsyms++;
df2627
df2627
	if (!(mapstrv = calloc(nsyms+1,sizeof(const char *))))
df2627
		return SLBT_SYSTEM_ERROR(dctx,0);
df2627
df2627
	for (nsyms=0,symv=mctx->symstrv; *symv; symv++)
df2627
		mapstrv[nsyms++] = *symv;
df2627
df2627
	qsort(mapstrv,nsyms,sizeof(const char *),slbt_strcmp);
df2627
df2627
	mctx->mapstrv = mapstrv;
df2627
df2627
	return 0;
df2627
}