From 17238f1ee52ddb9d9ef4282498de3b4406245a7f Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 27 Mar 2007 15:18:17 -0600 Subject: [PATCH] added _slang_label_new_unique() --- src/mesa/shader/slang/slang_label.c | 21 +++++++++++++++++++++ src/mesa/shader/slang/slang_label.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c index 4d35d2e72a1..e6a03f9e4f0 100644 --- a/src/mesa/shader/slang/slang_label.c +++ b/src/mesa/shader/slang/slang_label.c @@ -21,6 +21,27 @@ _slang_label_new(const char *name) return l; } +/** + * As above, but suffix the name with a unique number. + */ +slang_label * +_slang_label_new_unique(const char *name) +{ + static int id = 1; + slang_label *l = (slang_label *) _mesa_calloc(sizeof(slang_label)); + if (l) { + l->Name = (char *) _mesa_malloc(_mesa_strlen(name) + 10); + if (!l->Name) { + _mesa_free(l); + return NULL; + } + _mesa_sprintf(l->Name, "%s_%d", name, id); + id++; + l->Location = -1; + } + return l; +} + void _slang_label_delete(slang_label *l) { diff --git a/src/mesa/shader/slang/slang_label.h b/src/mesa/shader/slang/slang_label.h index 661624f173b..0f1a45b30f9 100644 --- a/src/mesa/shader/slang/slang_label.h +++ b/src/mesa/shader/slang/slang_label.h @@ -25,6 +25,9 @@ typedef struct slang_label_ slang_label; extern slang_label * _slang_label_new(const char *name); +extern slang_label * +_slang_label_new_unique(const char *name); + extern void _slang_label_delete(slang_label *l); -- 2.30.2